Resin web server

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(migration)
(migration)
Line 43: Line 43:
 
When starting Resin with [[httpd.sh]], pass the [[-J-d64]] option.
 
When starting Resin with [[httpd.sh]], pass the [[-J-d64]] option.
  
=== Deploying on Unix ===
+
=== Deploying ===
 +
 
 +
{{See also|site structure}}
  
 
When deploying, it's a good idea to create a bit of structure to
 
When deploying, it's a good idea to create a bit of structure to
 
make Resin and website upgrades easier and more maintainable.
 
make Resin and website upgrades easier and more maintainable.
In particular the [[-server-root]] option provides the ability to create structure for your website.
+
In particular the [[-server-root]] option provides the ability to create
 +
structure for your website.
  
 
# Create a user to run Resin (e.g. resin or another non-root user)
 
# Create a user to run Resin (e.g. resin or another non-root user)
Line 61: Line 64:
  
 
=== bin/httpd.sh ===
 
=== bin/httpd.sh ===
 +
 +
{{main|httpd.sh}}
  
 
<tt>bin/httpd.sh</tt> uses a perl script, <tt>resin-3.0.x/bin/wrapper.pl</tt>,
 
<tt>bin/httpd.sh</tt> uses a perl script, <tt>resin-3.0.x/bin/wrapper.pl</tt>,
Line 76: Line 81:
  
 
=== Site specific daemon script ===
 
=== Site specific daemon script ===
 +
 +
{{main|daemon}}
  
 
You can create your own [[daemon]] script which will start and stop
 
You can create your own [[daemon]] script which will start and stop
Line 152: Line 159:
 
<!-- /pre -->
 
<!-- /pre -->
  
=== Deploying a Windows service ===
+
=== Deploying ===
 +
 
 +
{{See also|site structure}}
 +
 
 +
When deploying, it's a good idea to create a bit of structure to
 +
make Resin and website upgrades easier and more maintainable.
 +
In particular the [[-server-root]] option provides the ability to create
 +
structure for your website.
 +
 
 +
==== Windows service ===
  
 
The Resin Web Server can be installed as an Windows service.
 
The Resin Web Server can be installed as an Windows service.
Line 205: Line 221:
  
 
== Command-line options ==
 
== Command-line options ==
 +
 +
{{main|command line option}}
  
 
<table>
 
<table>

Revision as of 09:02, 14 February 2006

Contents

Unix (including MacOS-X)

Getting started

(prompt) tar -xzvf resin-pro-3.0.x.tar.gz
(prompt) cd resin-pro-3.0.x
(prompt) ./configure; make; make install
 
(prompt) bin/httpd.sh
 
Resin-3.0.x (built Fri, 03 Feb 2006 09:47:48 EST)
Copyright(c) 1998-2006 Caucho Technology.  All rights reserved.
 
Starting Resin on Mon, 13 Feb 2006 20:16:19 -0500 (EST)
 
[20:16:23.367] Server[] starting
...
[20:16:23.453] http listening to *:8080
...

The following steps will start Resin for development:

  1. Install JDK 1.4 or later and link /usr/java to the Java home or set environment variable JAVA_HOME.
  2. Download Resin from the [download] page
  3. Untar resin-pro-3.0.x.tar.gz
  4. Change directory to resin-pro-3.0.x
  5. Build Resin ./configure; make; make install
  6. Execute bin/httpd.sh
  7. Browse http://localhost:8080

./configure options

Main article: configure script
OptionDescription
--enable-64bitcompiles the JNI using 64-bits

The 64-bit JNI compilation must match the JDK you're using. The --enable-64bit compiles the JNI code as 64 bit. When starting Resin with httpd.sh, pass the -J-d64 option.

Deploying

See also: site structure

When deploying, it's a good idea to create a bit of structure to make Resin and website upgrades easier and more maintainable. In particular the -server-root option provides the ability to create structure for your website.

  1. Create a user to run Resin (e.g. resin or another non-root user)
  2. Link /usr/local/resin to the current Resin version.
  3. Create a deployment root, e.g. /var/www, owned by the resin user. This is -server-root.
  4. Put the modified resin.conf in /var/www/conf/resin.conf
  5. Put the site documents in /var/www/webapps/ROOT/
  6. Access logs will appear in /var/www/logs/
  7. Output logs will appear in /var/www/log/
  8. Put any .war files in /var/www/webapps/
  9. Virtual hosts are created by adding directories in /var/www/hosts/, e.g. /var/www/hosts/gryffindor.hogwarts.com/ and /var/www/hosts/slytherin.hogwarts.com/
  10. Create a daemon startup script and configure the server to start it when the machine reboots.

bin/httpd.sh

Main article: httpd.sh

bin/httpd.sh uses a perl script, resin-3.0.x/bin/wrapper.pl, to control the Java process (bin/httpd.sh is a tiny shell script that calls wrapper.pl). You can modify bin/httpd.sh.

If you need to stop Resin with kill, you'll need to kill the wrapper.pl process to make sure it doesn't restart Resin. httpd.sh stop works by killing the wrapper.pl process. or bin/wrapper.pl for your configuration.

In a production environment, the "start" and "stop" options to bin/httpd.sh start and stop Resin as a Unix daemon. If Resin should ever exit, it will automatically be restarted.

Site specific daemon script

Main article: daemon

You can create your own daemon script which will start and stop your Resin instance, and pass any command-line options. This script can be placed in /etc/init.d and work cooperatively with the operating systems standard daemon control system. The script typically does a number of things:

  1. Configures the location of Java in JAVA_HOME
  2. Configures the location of Resin in RESIN_HOME
  3. Configures your web site directory in SERVER_ROOT
  4. Selects a server and pid file if you have multiple Resin servers.
  5. Starts and stops the Resin daemon.

An example is included in the Resin distribution resin-pro-3.0.x/contrib/init.resin.

A simple daemon script looks like:

#!/bin/sh

JAVA_HOME=/usr/java
RESIN_HOME=/usr/local/resin
SERVER_ROOT=/usr/local/web

export JAVA_HOME
export RESIN_HOME
export SERVER_ROOT

$RESIN_HOME/bin/httpd.sh -server-root $SERVER_ROOT \
                         -conf $SERVER_ROOT/conf/resin.conf \
                         -server a -pid $SERVER_ROOT/a.pid \\
                         $*

The script is invoked with ./resin start to start and ./resin stop to stop.

The -server and -pid options are only necessary if you have multiple JVMs either on different machines or the same machine. The load balancing and distributed sessions topics describe usage of -server and -pid.

Port forwarding

Main article: Port forwarding

Unix systems require root privileges to bind to ports less than 1024. Running the Resin process as root is not advised for security reasons. Port forwarding details operating system specific techniques for forwarding privileged ports to the ports that Resin is bound to.

Windows

Getting started

  1. Install JDK 1.4 or later.
  2. Make sure the JDK installation set the environment variable JAVA_HOME correctly
  3. Unzip resin-3.0.x.zip
  4. Execute resin-3.0.x\httpd.exe
  5. Browse http://localhost:8080
 (prompt) cd resin-pro-3.0.x
 (prompt) httpd.exe

 Resin-pro-3.0.x (built Fri, 03 Feb 2006 09:47:48 EST)
 Copyright(c) 1998-2006 Caucho Technology.  All rights reserved.
  
 Starting Resin on Mon, 13 Feb 2006 20:16:19 -0500 (EST)
  
 [20:16:23.367] Server[] starting

 ...

Deploying

See also: site structure

When deploying, it's a good idea to create a bit of structure to make Resin and website upgrades easier and more maintainable. In particular the -server-root option provides the ability to create structure for your website.

= Windows service

The Resin Web Server can be installed as an Windows service. To install the service, use:

 (prompt) httpd.exe -install -conf conf/resin.conf

To remove the service, use -remove:

 (prompt) httpd.exe -remove

You will either need to reboot the machine or start the service from the Control Panel | Services panel to start the server. On a machine reboot Windows will automatically start the web server.

You can also start and stop the service from the command-line:

 (prompt) net start resin
 ...
 (prompt) net stop resin

The -server option is used if you have multiple JVMs either on different machines or the same machine. The load balancing and distributed sessions topics describe usage of -server.

Resin's -install option saves the command-line options and starts the service with those options. You can look at them in the control panel, under the executable string.

With multiple servers, you can use ""-install-as name" to specify a unique service name.

 (prompt) httpd.exe -install-as ResinA -conf conf/myconf.conf -server a
 (prompt) net start ResinA

There is a bug in many JDKs which cause the JDK to exit when the administrator logs out. You can avoid that bug if the JDK is started with -Xrs

 (prompt) httpd.exe -install -Xrs

Command-line options

Main article: command line option
OptionDescriptionDefault
-verboseShow the Java environment before starting Resin.off
-conf xxxSelects the Resin configuration fileconf/resin.conf
-java_home xxxSets the JDK (also recognizes the environment variable JAVA_HOME.)A heuristic search
-resin_home xxxSets the Resin home directory (also recognizes the environment variable RESIN_HOME.)The parent directory of wrapper.pl
-classpath xxxAdds to the system classpath.$CLASSPATH
-pid xxx(Unix) With start or stop, sets the file to save the process id.resin.pid
-stdout xxxSets the file to save stdout messages.log/stdout.log.
-stderr xxxSets the file to save stdout messages.log/stderr.log.
-Dmy.foo=valueSets a Java system property.n/a
-XxxxPasses the -Xxxx command to the JDK.n/a
-JxxxPasses xxx as a JDK argument.n/a
-nojitDisables the Just-In-Time compiler. Useful for debugging.enabled
start(Unix) Starts Resin as a daemon, saving the pid in the pid file.n/a
stop(Unix) Stops Resin as a daemon, using the pid in the pid file.n/a
restart(Unix) Restarts Resin as a daemon, using the pid in the pid file.n/a
-install(Windows) install Resin as a service (but doesn't automatically start.)n/a
-install-as xxx(Windows) install Resin as a named service (but doesn't automatically start.)n/a
-remove(Windows) install Resin as a service (but doesn't automatically start.)n/a
-remove-as xxx(Windows) remove Resin as a named service (but doesn't automatically start.)n/a

Memory configuration

Main article: Command line options#Memory settings

Memory configuration is part of the JVM's options. For most JVMs, you can find the full list by starting "java -X".

-Xms<size>Initial Java heap size, e.g. -Xms32m
-Xmx<size>Maximum Java heap size, e.g. -Xmx128m

Starting Java directly

You can use the -verbose option to see the arguments the startup scripts/executables pass to the JDK. The IDE section also contains information about starting Resin directly from Java.

Personal tools