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 systemd script for [[/egg/spiffy|Spiffy the webserver]], for use on systems using the systemd daemon manager. Systemd requires two files to be placed in two different locations: * A plain text script file named "spiffy" * A plain text service file named "spiffy.service" Be sure to make both files executable and owned by root. The spiffy file, to be placed in /usr/lib/systemd/scripts/ <enscript highlight="shell"> #! /bin/sh # -*- shell-script -*- # This is /etc/init.d/spiffy on Linux systems using systemd # 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" start() { if [ ! -d "$LOG_DIR" ]; then echo "Log directory \"$LOG_DIR\" does not exist." exit 1 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 1 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 } 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) start ;; stop) stop ;; restart) stop sleep 1 start ;; *) exit 1 esac </enscript> The spiffy.service file, to be placed in /usr/lib/systemd/system/ <enscript highlight="shell"> [Unit] Description=Spiffy the webserver [Service] Type=oneshot ExecStart=/usr/lib/systemd/scripts/spiffy start ExecStop=/usr/lib/systemd/scripts/spiffy stop RemainAfterExit=yes [Install] WantedBy=multi-user.target </enscript> Now you can start, stop or restart Spiffy using the following commands: <enscript highlight="shell">$ systemctl start spiffy</enscript> <enscript highlight="shell">$ systemctl stop spiffy</enscript> <enscript highlight="shell">$ systemctl restart spiffy</enscript> To enable Spiffy to be started at boot: <enscript highlight="shell">$ systemctl enable spiffy</enscript>
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 10 to 4?