Skip to content

Instantly share code, notes, and snippets.

@zembutsu
Created November 25, 2013 11:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save zembutsu/7640108 to your computer and use it in GitHub Desktop.
Save zembutsu/7640108 to your computer and use it in GitHub Desktop.
Serf SysV Init script usage: # /sbin/chkconfig --add serf # /sbin/chkconfig serf on # /sbin/service serf start
#!/bin/sh
#
# chkconfig: - 89 11
# description: serf daemon
# processname: serf
# config: /etc/serf.conf
# Default-Start:
# Default-Stop: 0 1 2 3 4 5 6
# Description: serf agent daemon
# Source function library.
. /etc/rc.d/init.d/functions
exec=/usr/local/bin/serf
prog=${exec##*/}
conf=/etc/serf.conf
lockfile=/var/lock/subsys/serf
start ()
{
echo -n $"Starting Serf:"
if [ -f $conf ]; then
$exec agent -config-file=$conf &
else
$exec agent &
fi
#$exec agent > /dev/null &
stat=$?
echo
[ $stat -eq 0 ] && touch $lockfile
return $stat
}
stop()
{
echo -n $"Shutting down Serf:"
killproc $prog
stat=$?
echo
[ $stat -eq 0 ] && rm -f $lockfile
return $stat
}
restart()
{
stop
start
}
monitor ()
{
echo -n $"Monitoring Serf:"
$exec monitor &
return
}
leave()
{
echo -n $"Force-leave Serf:"
$exec force-leave node &
# stop
stat=$?
echo
[ $stat -eq 0 ] && rm -f $lockfile
return $stat
}
case "$1" in
start|stop|restart|monitor|leave)
$1
;;
force-reload)
restart
;;
status)
status $prog
;;
*)
echo $"Usage: $0 {start|stop|status|restart|monitor|leave}"
exit 2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment