I've been trying to understand how to setup systems from
the ground up on Ubuntu. I just installed redis
onto
the box and here's how I did it and some things to look
out for.
To install:
sudo apt-get install redis-server
That will create a redis
user and install the init.d
script for it. Since upstart
is now the replacement for
using init.d
, I figure I should convert it to run using
upstart
.
To disable the default init.d
script for redis
:
sudo update-rc.d redis-server disable
Then create /etc/init/redis-server.conf
with the following
description "Redis Server"
author "Thomas Woolford <[email protected]>"
# run when the local FS becomes available
start on local-filesystems
stop on shutdown
# The default redis conf has `daemonize = yes` and will naiively fork itself.
expect fork
# Respawn unless redis dies 10 times in 5 seconds
respawn
respawn limit 10 5
# start a default instance
instance $NAME
env NAME=redis
# run redis as the correct user
setuid redis
setgid redis
# run redis with the correct config file for this instance
exec /usr/bin/redis-server /etc/redis/${NAME}.conf
What this is is the script for upstart
to know what command to run
to start the process.
Now you can use the folowing commands to control your redis-server
:
sudo start redis-server [ name=redis ]
sudo restart redis-server [ name=redis ]
sudo status redis-server [ name=redis ]
sudo stop redis-server [ name=redis ]
Hope this was helpful!
Shell script version: https://gist.github.com/rogerleite/5927948#file-redis-install-sh
Thanks!