Drop Redis

I first ran Redis on my local computer, and then closed all the terminal windows after I disconnected the Rails application. An hour later, I started the Rails application again and did the following to start the redis server

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

However he told me

 # Opening port 6379: bind: Address already in use 

Therefore, I assumed that it was still launching its previous instance, although I closed the terminal windows on my Mac.

Looking at this page http://redis.io/commands/shutdown , I tried to run

 SHUTDOWN 

in the terminal window, but I get this answer

 SHUTDOWN: NOT super-user 

So I tried (although I did not use sudo to run it)

 sudo SHUTDOWN 

and after he asked me about my password, he displays this

 usage: shutdown [-] [-h [-u] [-n] | -r [-n] | -s | -k] time [warning-message ...] 

but when I accidentally ran shutdown -s , he said

  SHUTDOWN: NOT super-user 

What is the correct way to disable Redis when closing the application?

+6
source share
3 answers

This is intended to be sent as a redis command, and not to be executed on your terminal.

In this case, you can actually just kill redis from the terminal, because after receiving the SIGTERM signal, it plans to schedule SHUTDOWN instead of just exiting.

See the signal processing document page for reference.

+4
source

Use the built-in redis client: redis-cli shutdown

+34
source

Find out the process ID of the Redis instance running on your computer ...

 > ps aux | grep redis impadmin 23277 0.0 0.0 35044 1976 pts/2 Sl+ 14:19 0:00 src/redis-server 

... and then run:

 > kill 23277 
+3
source

All Articles