Skip to content

Instantly share code, notes, and snippets.

@pperehozhih
Created August 4, 2017 10:44
Show Gist options
  • Save pperehozhih/c312672ce1ed8ea081e5f1c24557382a to your computer and use it in GitHub Desktop.
Save pperehozhih/c312672ce1ed8ea081e5f1c24557382a to your computer and use it in GitHub Desktop.
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=nginx
PIDFILE=./obj/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=./obj/nginx
case "$1" in
start)
echo -n "Starting daemon: "$NAME
$DAEMON -t -c ./conf/nginx.conf -p "" -g "pid ${PIDFILE};"
echo "."
;;
stop)
echo -n "Stopping daemon: "$NAME
kill -QUIT $( cat ${PIDFILE} )
echo "."
;;
restart)
echo -n "Restarting daemon: "$NAME
kill -QUIT $( cat ${PIDFILE} )
$DAEMON -t -c ./conf/nginx.conf -p "" -g "pid ${PIDFILE};"
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