Skip to content

Instantly share code, notes, and snippets.

@scottjbarr
Created January 19, 2010 07:55
Show Gist options
  • Select an option

  • Save scottjbarr/280760 to your computer and use it in GitHub Desktop.

Select an option

Save scottjbarr/280760 to your computer and use it in GitHub Desktop.
Startling startup script
#!/bin/sh -e
#
# starling This init.d script is used to start starling.
# It basically just calls starling.
#
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
STARLING="/usr/local/bin/starling"
set -e
if [ -x $STARLING ] ; then
HAVE_STARLING=1
else
echo "No starling gem installed. Please run 'gem install starling'."
exit 0
fi
. /lib/lsb/init-functions
# ROOT="YOUR_WEB_APP"
PID="/var/run/starling.pid"
QPATH="/var/spool/starling"
IP_ADDRESS=0.0.0.0
PORT=22122
STARLING="$ENV $STARLING -d -P $PID -q $QPATH -h $IP_ADDRESS -p $PORT"
starling_stop() {
if [ -e $PID ]; then
if kill `cat $PID`; then
return 0
else
return 1
fi
else
log_failure_msg "Unable to find starling's PID. Please make sure that starling is running, and pid file is in ${PID}"
return 1
fi
}
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
case $1 in
start)
log_daemon_msg "Starting message server" "starling"
if $STARLING; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping message server" "starling"
if starling_stop; then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting message server" "starling"
if ! starling_stop; then
log_end_msg 1 || true
fi
sleep 2
if $STARLING; then
log_end_msg 0
else
log_end_msg 1
fi
;;
*)
log_success_msg "Usage: /etc/init.d/starling {start|stop|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment