Caucho maker of Resin Server | Application Server (Java EE Certified) and Web Server


Resin Documentation

home company blog wiki docs 
app server 
 Resin Server | Application Server (Java EE Certified) and Web Server

how to start resin when linux boots


Thanks to Guy McArthur and Carlos Hanson for the examples and much of the explanation for this tutorial.


The easiest way to start Resin when Linux boots is to modify your and create symbolic link in /etc/rc.d/rc3.d and /etc/rc.d/rc5.d. Because the boot process does not set environment variables, you'll need to set them in the

  1. Copy to "" in resin/bin and change permissions.
  2. Configure JAVA_HOME, RESIN_HOME, PATH, and "-pid" in
  3. Check that " start" and " stop" work from the command line when running as root.
  4. "ln -s /usr/local/resin/bin/ /etc/rc.d/rc3.d/S86resin-a"
  5. "ln -s /usr/local/resin/bin/ /etc/rc.d/rc5.d/S86resin-a"
  6. "ln -s /usr/local/resin/bin/ /etc/rc.d/rc2.d/K14resin-a"
  7. Reboot to test.

A sample might look like:

#! /bin/sh
# ...
export JAVA_HOME


export PATH

args="-Xms75M -Xmx100M start -pid $RESIN_HOME/"


exec $perl $RESIN_HOME/bin/ -chdir -name "$name" \
                                      -class "$class" $args $*

An advantage of this method is that you can use the same script to start and start the server interactively.

Linux booting background

At startup, Linux runs the /etc/rc.d/rc script at the current runlevel (normally 3 or 5). All the Sxx scripts in /etc/rc.d/rc3.d/S* are started in order.

Fragment of the rc script
for i in /etc/rc$runlevel.d/S*; do
  $i start

So S86resin-a will be called as "S86resin-a start" as the root user. Since the script can't assume any environment variables, it needs to set them itself.

Since Resin is an application, as opposed to a system service, it should be started late in the boot process. S86 is a decent choice. The specific order only matters if your startup depends on another service. For example, if you have a load-on-startup servlet that depends on a database, the database should be S85 or lower.

Some configurations boot up in runlevel 3 and others boot in runlevel 5. The actual boot order will then be {1,2,3} or {1,2,5}. A machine booting with runlevel 3 will have /etc/inittab with the following line:

/etc/inittab fragment

On server shutdown, Linux calls the scripts in /etc/rc.d/rc2.d/K* in order.

for i in /etc/rc$runlevel.d/K*; do
  $i stop

In this case, Resin is an application, as opposed to a system service, it should be killed early in the shutdown process.


An alternative to modifying the is to create another script that passes arguments to the original


# script name: resin 
# start/stop script for Resin 


${RESIN_HOME}/bin/ -Xms75M -Xmx100M \
    -java_home ${JAVA_HOME} "$*" 

Guy McArthur writes

I find it a bit easier to edit rather than creating a script that passes in environment variables. But that's just because I'll be starting/stopping resin manually using to try something out, so having that single point of control is good.

Carlos Hanson writes:

I originally started by editing, but having a script that passes the necessary arguments to allows me to reinstall or upgrade Resin more easily. All I have to worry about is configuration files. This is important when dealing with developers new to Unix and maintaining a large number of production and development servers. We keep the script and the conf files in source control.

Copyright © 1998-2012 Caucho Technology, Inc. All rights reserved. Resin ® is a registered trademark. Quercustm, and Hessiantm are trademarks of Caucho Technology.

Cloud-optimized Resin Server is a Java EE certified Java Application Server, and Web Server, and Distributed Cache Server (Memcached).
Leading companies worldwide with demand for reliability and high performance web applications including, CNET, DZone and many more are powered by Resin.

home company blog wiki docs 
app server