Skip to content

Instantly share code, notes, and snippets.

@kevintyll
Created December 15, 2009 19:26
Show Gist options
  • Save kevintyll/257214 to your computer and use it in GitHub Desktop.
Save kevintyll/257214 to your computer and use it in GitHub Desktop.
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
# Description: redis-server - Persistent key-value db
### END INIT INFO
source /etc/init.d/functions
DAEMON=/usr/bin/redis-server
DAEMON_ARGS=/etc/redis.conf
PROG="redis-server"
DESC="redis-server"
test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0
RETVAL=0
start() {
# Check if redis is already running
if [ ! -f /var/lock/subsys/$PROG ]; then
echo -n $"Starting $PROG: "
daemon $DAEMON $DAEMON_ARGS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROG
echo
fi
return $RETVAL
}
stop() {
echo -n $"Stopping $PROG: "
killproc $DAEMON
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
echo
return $RETVAL
}
restart() {
stop
start
}
reload() {
restart
}
status_at() {
status $DAEMON
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload|restart)
restart
;;
condrestart)
if [ -f /var/lock/subsys/$PROG ]; then
restart
fi
;;
status)
status_at
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac
exit $?
exit $RETVAL
@rhysce
Copy link

rhysce commented Jul 6, 2010

Thanks for this. I did have to append an ampersand onto daemon $DAEMON $DAEMON_ARGS but with that it worked perfectly for me.

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