How do I restart redis that I installed with brew?

66

28

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?

chovy

Posted 2012-11-13T06:31:47.720

Reputation: 1 017

Answers

19

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.

chovy

Posted 2012-11-13T06:31:47.720

Reputation: 1 017

2See the other answer that uses launchctl, it works and is supported now by the brew recipe. – oDDsKooL – 2014-10-23T06:46:06.230

1I've appended this command with '& disown' to background and detach from the process – Ben Simpson – 2014-01-02T19:36:01.887

64

update

brew services expired due to no one want to maintain it. check below: https://github.com/Homebrew/homebrew/issues/28657

check launchctl function instead.

or lunchy

So instead of:

launchctl load ~/Library/LaunchAgents/io.redis.redis-server.plist

you can do this:

lunchy start redis

and:

lunchy ls

references: https://github.com/eddiezane/lunchy

It used to be able to use as below:

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.

ken

Posted 2012-11-13T06:31:47.720

Reputation: 884

2I had to re-install redis with brew to get it in the startup plist, then this worked fine – Stuart Nelson – 2014-06-26T15:27:23.167

1"Warning: brew services is unsupported and will be removed soon." – user72923 – 2014-09-13T17:25:16.793

2It'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 – 2014-10-04T05:50:24.690

3brew doesn't support the "services" verb anymore as of 0.9.5 – oDDsKooL – 2014-10-23T06:38:23.517

Use the answer below using launchctl, now that brew doesn't support "services" anymore – Daniel Magliola – 2015-02-19T14:43:32.430

4Please note that brew does support the the services command now via a tap. See the answer below, it is a more relevant answer now. – GrayedFox – 2016-11-03T15:50:10.110

38

As of Dec-7-2015 You can use brew services.

You need to brew tap homebrew/services and then thw following will work as expected:

install brew install redis

start brew services start redis

stop brew services stop redis

restart brew services restart redis

More info here: https://github.com/Homebrew/homebrew-services

microspino

Posted 2012-11-13T06:31:47.720

Reputation: 911

conflicting answer above says brew services is deprecated. – chovy – 2015-12-08T10:20:30.900

5@chovy They were deprecated because of lack of maintenance, but are now back again as a brew tap. As you can see last commit is from 27 days ago. – microspino – 2015-12-08T11:28:37.087

3This is a more relevant and up to date answer now than the above ones, and faster to implement than going manual launchctl way. – GrayedFox – 2016-11-03T15:51:23.467

2It's 2017 and I'm using Brew v1.3.6 and this works perfectly fine. – Ryan Taylor – 2017-10-27T21:42:38.773

23

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

oDDsKooL

Posted 2012-11-13T06:31:47.720

Reputation: 331

brew 0.9.5 support services, here they are
$ brew --version Homebrew 0.9.5 (git revision bf22; last commit 2016-03-06) $ brew services list Name Status User Plist postgresql stopped
redis stopped
$
– AMIC MING – 2016-03-22T19:14:02.983

1

For Homebrew 1.5.14

redis-server

Miguel Coder

Posted 2012-11-13T06:31:47.720

Reputation: 111

4

Welcome to Super User! This duplicates information present in another answer- can you differentiate it at all? :)

– bertieb – 2018-05-01T17:44:27.350

Now it's the same as the accepted answer!! (You really should just delete this answer.)

– robinCTS – 2018-07-27T03:58:33.743

no it's not. He included the path to a conf file. Clearly not the same, and not required. I know I don't want to type the path to a conf file every time I start and stop Redis and I think anyone else reading this(besides you) would find that valuable. – Miguel Coder – 2018-07-27T18:31:38.173