####here's where this solution was pulled from: Ted Naleid's blog
####minor changes in this gist:
- service name => calling
io.redis.redis-server
seemed like too much,redis
is easier to remember - using nano instead of vim in steps since working with vim is awkward if you don't do it often
####steps:
- stop of all of your running redis instances
ps aux | grep redis
=> returns a list of all of the redis processeskill -9 insert-pid-here
=> call that for each of the PIDs theps
call returns
- open up
nano
to new service definition file
sudo nano /Library/LaunchDaemons/redis.plist
- paste this into that
nano
session:
<?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>redis</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/redis-server</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
- save and close =>
ctrl + x, y, enter
- load the new system service (only once, ever)
sudo launchctl load /Library/LaunchDaemons/redis.plist
- now you can do these things all the time:
sudo launchctl start redis
sudo launchctl stop redis
And now, Redis will always start on boot - we should never have to worry about it again. If you're not developing and want to save some battery, sudo launchctl stop redis
. This will not affect launch-on-boot - when you reboot, redis will have started on its own again 🤘