Skip to content

Instantly share code, notes, and snippets.

@gsf
Last active December 21, 2015 00:39
Show Gist options
  • Save gsf/6222405 to your computer and use it in GitHub Desktop.
Save gsf/6222405 to your computer and use it in GitHub Desktop.
ploy init
#!/bin/sh
### BEGIN INIT INFO
# Provides: ploy
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts ploy services
# Description: starts services with ploy
### END INIT INFO
# adapted from nginx init 2011-10-17 gsf
# also borrowed a few ideas from https://gist.github.com/715255
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/ploy
DIR=/usr/local/var/lib/ploy
DESC="ploy server"
NAME=ploy
OUTLOG=/usr/local/var/log/ploy/ploy.log
ERRLOG=/usr/local/var/log/ploy/ploy.log
AUTH=/usr/local/etc/ploy/auth.json
PORTS='ls $DIR'
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
echo -n "Starting $DESC: "
for port in $PORTS; do
daemon -n $NAME$port -O $OUTLOG -E $ERRLOG -- $DAEMON server $DIR/$port -p $port -a $AUTH
done
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
for port in $PORTS; do
daemon -n $NAME$port --stop
done
echo "$NAME."
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $NAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment