Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
Here's an example init.d script for [[/egg/spiffy|Spiffy the webserver]], for use on Debian derivatives (created by [[/users/mario-domenech-goulart|Mario Domenech Goulart]]). This script has also been prepared to play well with the "chkconfig" command on Red Hat derivatives (Fedora, CentOS, ...). See below for a lsb-compatible script. <enscript highlight="shell"> #! /bin/sh # -*- shell-script -*- # Make this script chkconfig compliant, start with runlevel 2345, exit prio 95 (lower) start prio 20 (higher) # chkconfig: 2345 95 20 # description: Control script for the Spiffy CHICKEN webserver # processname: spiffy # This is /etc/init.d/spiffy on Debian systems # It assumes you have a "spiffy.scm" script in /usr/local/libexec and a log directory in /var/log/spiffy # Select which "csi" program to use; defaults to the one in $PATH CSI=csi # Use a longer trace buffer and a larger nursery size (optional) CSI_ARGS="-:s1m -:a200" DATE_FORMAT="+%Y-%m-%d %H:%M:%S" CONFIG_FILE="/usr/local/libexec/spiffy.scm" LOG_DIR="/var/log/spiffy" spiffy_start () { if [ ! -d "$LOG_DIR" ]; then echo "Log directory \"$LOG_DIR\" does not exist." exit 0 fi if [ ! -r "$CONFIG_FILE" ]; then echo "Cannot find or read the configuration file. Please create or check the permissions of the following file: \"$CONFIG_FILE\"." exit 0 fi echo "Starting spiffy..." echo "start: " `date "$DATE_FORMAT"` >> /var/log/spiffy/start-stop.log (cd /var/log/spiffy; ulimit -c unlimited ; $CSI $CSI_ARGS -s /usr/local/libexec/spiffy.scm &) </dev/null &> /var/log/spiffy/init.log } spiffy_stop () { echo "Stopping spiffy..." echo "stop: " `date "$DATE_FORMAT"` >> /var/log/spiffy/start-stop.log pids=`ps ax | grep "[/]usr/local/libexec/spiffy.scm" | awk '{print $1}'` if [ -z "$pids" ] ; then echo "spiffy is not running" else for pid in $pids; do echo "killing " $pid kill $pid done fi } case "$1" in start) spiffy_start ;; stop) spiffy_stop ;; restart) spiffy_stop sleep 1 spiffy_start ;; *) exit 1 esac </enscript> The following script is compatible with LSB init.d scripts, and has been tested on a Debian Wheezy system: <enscript highlight="shell"> #! /bin/sh ### BEGIN INIT INFO # Provides: spiffy # Required-Start: $network # Required-Stop: $network # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Start Spiffy the webserver ### END INIT INFO . /lib/lsb/init-functions # Must make this script executable with a shebang line, or compile it DAEMON=/usr/local/libexec/spiffy.scm PIDFILE=/var/run/spiffy.pid test -x $DAEMON || exit 5 case $1 in start) log_daemon_msg "Starting web server" "spiffy" start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON --make-pidfile $PIDFILE --background log_end_msg $? ;; stop) log_daemon_msg "Stopping web server" "spiffy" start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE log_end_msg $? ;; restart|force-reload) $0 stop && sleep 2 && $0 start ;; try-restart) if $0 status > /dev/null; then $0 restart else exit 0 fi ;; reload) # not implemented exit 3 ;; status) status_of_proc $DAEMON "Spiffy" ;; *) echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}" exit 2 ;; esac </enscript>
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 10 to 3?