Created
May 4, 2012 14:39
-
-
Save hagane/2595171 to your computer and use it in GitHub Desktop.
Debian GNU/Linux init.d script for SBCL system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
#AUTHOR Hagane <[email protected]> | |
# * ---------------------------------------------------------------------------- | |
# * "THE BEER-WARE LICENSE" (Revision 42): | |
# * <[email protected]> wrote this file. As long as you retain this notice you | |
# * can do whatever you want with this stuff. If we meet some day, and you think | |
# * this stuff is worth it, you can buy me a beer in return. -- Hagane | |
# * ---------------------------------------------------------------------------- | |
# ! Note that you need to load and start SWANK node with .sbclrc, otherwise | |
# ! your Lisp system will be useless until you reattach and run SWANK manually. | |
### BEGIN INIT INFO | |
# Provides: sbcl | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: SBCL system startup script | |
# Description: This sc | |
### END INIT INFO | |
USERNAME=lisp | |
DESC="SBCL system" | |
NAME=sbcl | |
DAEMON_ARGS="/home/$USERNAME" | |
DAEMON=/usr/bin/sbclbg | |
PIDFILE=/home/$USERNAME/$NAME.pid | |
SCRIPTNAME=/etc/init.d/$NAME | |
# Exit if the package is not installed | |
[ -x "$NAME" ] || exit 0 | |
# Load the VERBOSE setting and other rcS variables | |
. /lib/init/vars.sh | |
# Define LSB log_* functions. | |
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. | |
. /lib/lsb/init-functions | |
do_start() { | |
start-stop-daemon -S -q -c $USERNAME -p $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2 | |
} | |
do_stop() { | |
start-stop-daemon -K -q --retry=TERM/30/KILL/5 -p $PIDFILE | |
RETVAL="$?" | |
[ "$RETVAL" = 2 ] && return 2 | |
# Try to kill children | |
start-stop-daemon -K -q --oknodo --retry=0/30/KILL/5 --exec $DAEMON | |
rm -f $PIDFILE | |
return $RETVAL | |
} | |
case "$1" in | |
start) | |
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | |
do_start | |
case "$?" in | |
0|1) log_end_msg 1 ;; | |
2) log_end_msg 2 ;; | |
esac;; | |
stop) | |
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | |
do_stop | |
case "$?" in | |
0|1) log_end_msg 1 ;; | |
2) log_end_msg 2 ;; | |
esac;; | |
restart) | |
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME" | |
do_stop | |
case "$?" in | |
0|1) | |
do_start | |
case "$?" in | |
0) log_end_msg 0;; | |
1) log_end_msg 1;; # Old process is still running | |
*) log_end_msg 1;; # Failed to start | |
esac;; | |
*) log_end_msg 1;; # Failed to stop | |
esac;; | |
*) echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Run SBCL system in background with detachtty. | |
detachtty --dribble-file $1/sbcl-dribble \ | |
--log-file $1/detachtty.log \ | |
--pid-file $1/sbcl.pid \ | |
$1/sbcl-socket /usr/bin/sbcl --dynamic-space-size 1024 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment