Skip to content

Instantly share code, notes, and snippets.

@ihor
Last active January 19, 2018 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ihor/3829558 to your computer and use it in GitHub Desktop.
Save ihor/3829558 to your computer and use it in GitHub Desktop.
/etc/init.d/redis script for Homebrew installed REdis
#!/bin/bash
DAEMON=/usr/local/bin/redis-server
OPTS=/usr/local/etc/redis/redis.conf
NAME=redis
DESC=redis
test -x $DAEMON || exit 0
set -e
start()
{
$DAEMON $OPTS > /var/log/redis/output.log 2>&1 &
return
}
stop()
{
PORT=`grep -E "^ *port +([0-9]+) *$" "$OPTS" | grep -Eo "[0-9]+"`
/usr/local/bin/redis-cli -p $PORT SHUTDOWN
return
}
case "$1" in
start)
echo -n "Starting $DESC: "
start
echo "started."
;;
stop)
echo -n "Stopping $DESC: "
stop
echo "stopped."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
stop
sleep 1
start
echo "restarted."
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment