13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

454Chapter 20Open Source Web <str<strong>on</strong>g>Applicati<strong>on</strong></str<strong>on</strong>g> Servers# Run gettys in standard runlevels1:2345:respawn:/sbin/mingetty tty12:2345:respawn:/sbin/mingetty tty23:2345:respawn:/sbin/mingetty tty34:2345:respawn:/sbin/mingetty tty45:2345:respawn:/sbin/mingetty tty56:2345:respawn:/sbin/mingetty tty6# Run xdm in runlevel 5x:5:respawn:/etc/X11/prefdm -nodaem<strong>on</strong>NOTESome <strong>Linux</strong> distributi<strong>on</strong>s run different scripts for each runlevel instead of passingthe runlevel as an argument to a single script. The details are not important.The net effect is that a script is run for each runlevel.Sure, you could put the code to run JBoss directly in that script if youwant. But these scripts have been designed to handle arbitrary sets of serviceswithout you having to modify those scripts directly. How? By doing what <strong>Linux</strong>(and its UNIX antecedents) does so well: making complex systems out ofsimple parts.Each service you might wish to start and stop gets a shell script that c<strong>on</strong>trolsit. This shell script must take a command argument. The minimum setof commands that must be supported are start and stop. Other opti<strong>on</strong>s suchas restart and status are often supported, but start and stop are theimportant <strong>on</strong>es.The script for atd, the <strong>on</strong>e-shot job scheduler, is a fine example. Let’s takea look at it (Example 20.2).Example 20.2 The atd init shell script#!/bin/bash## /etc/rc.d/init.d/atd## Starts the at daem<strong>on</strong>## chkc<strong>on</strong>fig: 345 95 5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!