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 httpd.sh 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 httpd.sh.
A sample resin-a.sh might look like:
An advantage of this method is that you can use the same script to start and start the server interactively.
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.
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:
On server shutdown, Linux calls the scripts in /etc/rc.d/rc2.d/K* in order.
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 httpd.sh is to create another script that passes arguments to the original httpd.sh.
Guy McArthur writes I find it a bit easier to edit wrapper.pl rather than creating a script that passes in environment variables. But that's just because I'll be starting/stopping resin manually using httpd.sh to try something out, so having that single point of control is good. Carlos Hanson writes: I originally started by editing wrapper.pl, but having a script that passes the necessary arguments to httpd.sh 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.
|