Skip to content

Instantly share code, notes, and snippets.

@tkling
Last active August 29, 2015 14:01
Show Gist options
  • Save tkling/a9d4a8705cad0864e494 to your computer and use it in GitHub Desktop.
Save tkling/a9d4a8705cad0864e494 to your computer and use it in GitHub Desktop.

Redis as an OSX service!

####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:

  1. stop of all of your running redis instances
  • ps aux | grep redis => returns a list of all of the redis processes
  • kill -9 insert-pid-here => call that for each of the PIDs the ps call returns
  1. open up nano to new service definition file
  • sudo nano /Library/LaunchDaemons/redis.plist
  1. 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>  
  1. save and close => ctrl + x, y, enter
  2. load the new system service (only once, ever)
  • sudo launchctl load /Library/LaunchDaemons/redis.plist
  1. 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 🤘

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