Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I used brew to install redis (a key/value store database server) for my node.js app.

brew install redis

However, it seems to disappear and is very volatile. Because I'm using redis as my session store, I need to be able to quickly restart it on my mac when this happens.

How do I restart redis that I installed with brew?

share|improve this question

3 Answers 3

brew services restart redis

should be the restart command You want. You can also run

brew services list

which will give you list of your brew services.

share|improve this answer
1  
I had to re-install redis with brew to get it in the startup plist, then this worked fine –  Stuart Nelson Jun 26 at 15:27
1  
"Warning: brew services is unsupported and will be removed soon." –  user72923 Sep 13 at 17:25
    
It's pretty dumb to remove such useful shortcut. But it's buggy by the way. I can stop redis with brew services, but after that I'm unable to start it again. –  Phuong Nguyen Oct 4 at 5:50
    
brew doesn't support the "services" verb anymore as of 0.9.5 –  oDDsKooL 4 hours ago

I found all these options listed in brew package (brew info redis) to be very buggy. For example redis throws a bunch of errors if it isn't started with root. I ended up just doing the direct call with sudo and removing launchctl files.

sudo redis-server /usr/local/etc/redis.conf

I was hoping there was a way to easily restart redis from the command line, but that doesn't seem possible. Therefore, I run with daemon mode set to 'no' and watch it log to stdout, then I can kill it easily.

share|improve this answer
    
I've appended this command with '& disown' to background and detach from the process –  Ben Simpson Jan 2 at 19:36
    
See the other answer that uses launchctl, it works and is supported now by the brew recipe. –  oDDsKooL 4 hours ago

Brew doesn't support the services command anymore.

The recommended way is to use os x's launchctl command.

First you need to setup redis as a service managed by launchctl:

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

Then you can use launchctl load/ launchctl unload to start/stop the service:

$ # start redis server
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
$
$ # stop redis server
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.