0

I have a Procfile that I use with Foreman to start my local redis and webrick server:

web: bundle exec rails server -p $PORT
redis: redis-server config/redis.development.conf

I connect to Redis using a named socket that is defined in the configuration like this:

unixsocket /tmp/redis-APPNAME.sock

Everything works fine in Rails, but when I hit CTRL+C to terminate Foreman in the terminal, the Redis DB is not dumped. The Redis server is terminated by SIGINT this way. So, whenever I restart the Foreman stack I get old Redis data.

Is there a way to tell Foreman to use the proper SHUTDOWN on Redis that will also dump the database? Or should I modify the Redis config to persist data all the time in development?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Martin Sojka
  • 523
  • 5
  • 18

2 Answers2

0

Have you tried using a wrapper script to send SIGTERM instead?

Musannif Zahir
  • 3,001
  • 1
  • 21
  • 31
  • If sending `SIGTERM` still does not cause Redis to save the dump file, call the [shutdown](http://redis.io/commands/shutdown) command: `redis-cli shutdown save`. – Jimothy Oct 30 '13 at 14:19
-1

I ended up using Append-only File persistance on my development laptop for Redis instances. To turn it on you just have to add appendonly yes to your redis config. I left the fsync option to 1 second.

This way I always get persisted data when I terminate Foreman and switch to another project.

More details about Redis persistance options here: http://redis.io/topics/persistence

Martin Sojka
  • 523
  • 5
  • 18