sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist
Paste in the following contents and modify it to point it to wherever you’ve got redis-server
installed and optionally pass the location of a config file to it (delete the redis.conf line if you’re not using one):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.redis.redis-server</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/redis-server</string>
<string>/usr/local/etc/redis.conf</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Make sure that you actually have a redis.conf
file at the location above. If you’ve installed it with homebrew that should be the correct location.
You’ll then need to load the file (one time) into launchd with launchctl
:
sudo launchctl load /Library/LaunchDaemons/io.redis.redis-server.plist
Redis will now automatically be started after every boot. You can manually start it without rebooting with:
sudo launchctl start io.redis.redis-server
You can also shut down the server with
sudo launchctl stop io.redis.redis-server
Or you could add these aliases to your bash/zsh rc file:
- alias redisstart=’sudo launchctl start io.redis.redis-server’
- alias redisstop=’sudo launchctl stop io.redis.redis-server’
If you’re having some sort of error (or just want to watch the logs), you can just fire up Console.app
to watch the redis logs to see what’s going on.