Created
June 3, 2014 07:56
-
-
Save kshcherban/9c08636af0ac11958e6a to your computer and use it in GitHub Desktop.
init script for unicorn puppet server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# unicorn-puppet | |
# chkconfig: - 98 02 | |
lockfile=/var/lock/puppetmaster-unicorn | |
pidfile=/var/run/puppet/puppetmaster_unicorn.pid | |
RETVAL=0 | |
DAEMON=/usr/bin/unicorn | |
DAEMON_OPTS="-D -c /etc/puppet/unicorn.conf" | |
start() { | |
$DAEMON $DAEMON_OPTS | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && touch "$lockfile" | |
echo | |
return $RETVAL | |
} | |
stop() { | |
kill `cat $pidfile` | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f "$lockfile" | |
return $RETVAL | |
} | |
restart() { | |
stop | |
sleep 1 | |
start | |
RETVAL=$? | |
echo | |
[ $RETVAL -ne 0 ] && rm -f "$lockfile" | |
return $RETVAL | |
} | |
condrestart() { | |
status | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && restart | |
} | |
status() { | |
ps ax | egrep -q "unicorn (worker|master)" | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; | |
then echo "Running" | |
else echo "Stopped" | |
fi | |
return $RETVAL | |
} | |
usage() { | |
echo "Usage: $0 {start|stop|restart|status|condrestart}" >&2 | |
return 3 | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
condrestart) | |
condrestart | |
;; | |
status) | |
status | |
;; | |
*) | |
usage | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment