Skip to content

Instantly share code, notes, and snippets.

@Kagee
Created June 23, 2013 20:12
Show Gist options
  • Save Kagee/5846367 to your computer and use it in GitHub Desktop.
Save Kagee/5846367 to your computer and use it in GitHub Desktop.
https://github.com/trinidad/trinidad/wiki/init.d-scripts
#!/bin/sh
set -e
# Must be a valid filename
NAME=trr
#/var/run/app must be writable by your user
PIDFILE=/var/run/app/trr.pid
DAEMON="/path/to/php"
DAEMON_OPTS="/path/to/update_daemon2.php"
USER=www-data
APPDIR="/apps/yourapp/current"
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
echo -n "Starting daemon: "$NAME
start-stop-daemon --start --chdir $APPDIR --quiet --chuid $USER --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
start-stop-daemon --stop --chdir $APPDIR --quiet --chuid $USER --oknodo --pidfile $PIDFILE
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
start-stop-daemon --stop --chdir $APPDIR --quiet --chuid $USER --oknodo --retry 30 --pidfile $PIDFILE
start-stop-daemon --start --chdir $APPDIR --quiet --chuid $USER --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
echo "."
;;
*)
echo "Usage: "$1" {start|stop|restart}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment