Resin web server

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
(migration)
(migartion)
Line 194: Line 194:
 
== Command-line options ==
 
== Command-line options ==
  
{{main|command line option}}
+
{{main|Command line option}}
  
<table>
 
<tr><th>Option</th><th>Description</th><th>Default</th></tr>
 
<tr><td>-verbose</td><td>Show the Java environment before starting Resin.</td><td>off</td></tr>
 
<tr><td>-conf ''xxx''<td>Selects the Resin configuration file<td>conf/resin.conf
 
<tr><td>-java_home ''xxx''<td>Sets the JDK (also recognizes the environment variable JAVA_HOME.)<td>A heuristic search
 
<tr><td>-resin_home ''xxx''<td>Sets the Resin home directory (also recognizes the environment variable RESIN_HOME.)<td>The parent directory of wrapper.pl
 
<tr><td>-classpath ''xxx''<td>Adds to the system classpath.<td>$CLASSPATH
 
<tr><td>-pid ''xxx''<td>(Unix) With ''start'' or ''stop'', sets the file
 
to save the process id.<td>resin.pid
 
<tr><td>-stdout ''xxx''<td>Sets the file to save stdout messages.<td>log/stdout.log.
 
<tr><td>-stderr ''xxx''<td>Sets the file to save stdout messages.<td>log/stderr.log.
 
<tr><td>-D''my.foo''=''value''<td>Sets a Java system property.<td>n/a
 
<tr><td>-X''xxx''<td>Passes the -X''xxx'' command to the JDK.<td>n/a
 
<tr><td>-J''xxx''<td>Passes ''xxx'' as a JDK argument.<td>n/a
 
<tr><td>-nojit<td>Disables the Just-In-Time compiler. Useful for debugging.<td>enabled
 
<tr><td>start<td>(Unix) Starts Resin as a daemon, saving the pid in the pid file.<td>n/a
 
<tr><td>stop<td>(Unix) Stops Resin as a daemon, using the pid in the pid file.<td>n/a
 
<tr><td>restart<td>(Unix) Restarts Resin as a daemon, using the pid in the pid file.<td>n/a
 
<tr><td>-install<td>(Windows) install Resin as a service (but doesn't automatically start.)<td>n/a
 
<tr><td>-install-as ''xxx''<td>(Windows) install Resin as a named service (but doesn't automatically start.)<td>n/a
 
<tr><td>-remove<td>(Windows) install Resin as a service (but doesn't automatically start.)<td>n/a
 
<tr><td>-remove-as ''xxx''<td>(Windows) remove Resin as a named service (but doesn't automatically start.)<td>n/a
 
</table>
 
  
 
== Memory configuration ==
 
== Memory configuration ==

Revision as of 11:32, 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.

bin/httpd.sh

Main article: httpd.sh

bin/httpd.sh is the script for starting the web server.

Developers commonly execute httpd.sh in a cmd window and log messages are displayed on the console.

 (prompt) bin/httpd.sh

Deploying

See also: site structure

It is 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 a maintainable file 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.

Site specific daemon script

Main article: daemon

httpd.sh accepts the start, stop, and restart options for executon as a 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

 ...

httpd.exe

Main article: httpd.exe

httpd.exe is the script for starting the web server.

Developers commonly execute httpd.exe in a cmd window and log messages are displayed on the console.

 (prompt) httpd.exe

Deploying

See also: site structure

It is 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 a maintainable file structure for your website.

Windows service

{{main|Windows service||

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

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

Command-line options

Main article: Command line option


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