Skip to content

Instantly share code, notes, and snippets.

@yureative
Created April 15, 2015 02:20
Show Gist options
  • Save yureative/a24358e537d05ec78a38 to your computer and use it in GitHub Desktop.
Save yureative/a24358e537d05ec78a38 to your computer and use it in GitHub Desktop.
init.d script of circus
#!/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 $?
@yureative
Copy link
Author

Before adding nohup is following.

daemon --pidfile="$PIDFILE" $DAEMON $DAEMON_ARGS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment