Created
April 15, 2015 02:20
-
-
Save yureative/a24358e537d05ec78a38 to your computer and use it in GitHub Desktop.
init.d script of circus
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 | |
### BEGIN INIT INFO | |
# Provides: circusd | |
# Required-Start: $remote_fs $network | |
# Required-Stop: $remote_fs $network | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: circus master control daemon | |
# Description: This is a daemon that controls the circus minions | |
### END INIT INFO | |
# source function library | |
. /etc/init.d/functions | |
RETVAL=0 | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DESC="circus daemon" | |
NAME=circusd | |
DAEMON=/usr/local/bin/circusd | |
PIDFILE=/var/run/$NAME.pid | |
CONFIG=/etc/circus/circusd.ini | |
LOGFILE=/var/log/circus/circus.log | |
BOOTLOG=/var/log/circus/circus.boot | |
DAEMON_ARGS="--log-output $LOGFILE --daemon --pidfile $PIDFILE $CONFIG" | |
# Exit if the package is not installed | |
[ -x "$DAEMON" ] || exit 5 | |
# Read configuration variable file if it is present | |
[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME | |
start() { | |
echo -n "Starting circusd daemon: " | |
daemon --pidfile="$PIDFILE" nohup $DAEMON $DAEMON_ARGS 2> $BOOTLOG | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n "Stopping $DESC ..." | |
killproc -p "$PIDFILE" $DAEMON | |
RETVAL=$? | |
echo | |
return $RETVAL | |
} | |
rhstatus() { | |
status -p "$PIDFILE" -l $NAME $DAEMON | |
} | |
restart() { | |
stop | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|force-reload) | |
restart | |
;; | |
status) | |
rhstatus | |
;; | |
condrestart|try-restart) | |
rhstatus >/dev/null 2>&1 || exit 0 | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart|condrestart|try-restart|force-reload|status}" | |
exit 3 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before adding nohup is following.