Skip to content

Instantly share code, notes, and snippets.

@tblobaum
Created August 9, 2012 12:04
Show Gist options
  • Save tblobaum/3303639 to your computer and use it in GitHub Desktop.
Save tblobaum/3303639 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# fleet-drone
#
# chkconfig: - 85 15
# description:
# processname: fleet-drone
# config: /etc/node/fleet-drone.conf
# pidfile: /var/run/fleet-drone.pid
# Source function library.
source /etc/rc.d/init.d/functions
# Source networking configuration.
source /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
# Source fleet-drone configuration.
source /etc/node/fleet-drone.conf
exec="$NODE_PATH/node $NODE_PATH/fleet-drone"
prog=$(basename $exec)
PATH=$NODE_PATH:$PATH
[ -e /etc/sysconfig/$prog ] && source /etc/sysconfig/$prog
lockfile=/var/lock/subsys/fleet-drone
start() {
echo -n $"Starting $prog: "
[ -d /opt/fleet-drone ] || mkdir /opt/fleet-drone
cd /opt/fleet-drone
# start it up here, usually something like "daemon $exec"
daemon NODE_ENV=$NODE_ENV $exec --hub $HUB --secret $HUB_SECRET &
echo $! > /var/run/fleet-drone.pid
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
killproc $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
force_reload() {
restart
}
fdr_status() {
status $prog
}
case "$1" in
start|stop|restart)
$1
;;
status)
fdr_status
;;
condrestart|try-restart)
[ ! -f $lockfile ] || restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|try-restart}"
exit 2
esac
check process fleet-drone with pidfile /var/run/fleet-drone.pid
group application
group nodejs
start program = "/etc/init.d/fleet-drone start"
stop program = "/etc/init.d/fleet-drone stop"
check file node.log with path /var/log/node.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment