I'm running redis with rq to queue tasks from a python dash web app. While developing I figured out that everything works fundamentally better after a fresh reboot As redis has some problem with restarting it's service, I decided to blame it for this behavior. Every time I add some lines of code I now ran:
rm dump.rdb
sudo service redis-server stop
lsof -ti tcp:6379 | xargs kill
kill -9 $(pgrep python)
redis-server & python app.py & worker.py
Is there anything more I can do to make sure redis really restarts? :D
Comment From: oranagra
redis doesn't have any other background services, so when you kill it and re-start it, it "really restarts"
if in addition to that you delete the dump.rdb, then it comes completely empty and fresh.
the only thing you might be missing is that because you killed it with -9, it didn't have a chance to terminate it's bgsave child if there was one.
if you'll kill it with normal SIGTERM (i.e. just kill) then it would kill the bgsave child on shutdown, but then it may decide to save an rdb file on exit. in order to avoid all of that you can do this instead:
redis-cli config set appendonly no
redis-cli shutdown nosave
if you prefer to keep killing with -9, you may wants to check if the child process is still alive.
these can be named: redis-aof-rewrite, redis-rdb-bgsave, or redis-rdb-to-slaves. depending on what you do with redis and it's configuration.
Comment From: luggie
just what I was hoping to read. Thanks!