Skip to content

Instantly share code, notes, and snippets.

@ideaoforder
Created August 21, 2009 17:43
Show Gist options
  • Select an option

  • Save ideaoforder/172235 to your computer and use it in GitHub Desktop.

Select an option

Save ideaoforder/172235 to your computer and use it in GitHub Desktop.
#!/bin/sh -e
# workling This init.d script is used to start workling.
# It basically just calls workling.
. /lib/lsb/init-functions
ROOT="YOUR_WEB_APP"
PID=$ROOT"log/workling$2.pid"
WORKLING=$ROOT"script/workling_client"
START_COMMAND=$WORKLING" start"
workling_stop() {
if [ -e $PID ]; then
if kill `cat $PID`; then
return 0
else
return 1
fi
else
log_failure_msg "Unable to find workling's PID. Please make sure that workling is running, and pid file is in /var/run/starling.pid"
return 1
fi
}
# Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
case $1 in
start)
log_daemon_msg "Starting workling" "workling"$2
if $START_COMMAND; then
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
log_daemon_msg "Stopping workling" "workling"$2
if workling_stop; then
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting workling" "workling"$2
if ! workling_stop; then
log_end_msg 1 || true
fi
sleep 2
if $START_COMMAND; then
log_end_msg 0
else
log_end_msg 1
fi
;;
*)
log_success_msg "Usage: /etc/init.d/workling {start|stop|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment