start redis with supervisor

When using Supervisord to manage server programs like databases that often spawn or daemonize, look for a flag in the startup command or in the config file. There is an exception with databases like MySQL where recommended practice is to use a proxy to start mysqld_safe and let it manage the sub processes.

In redis.conf for newer versions (i.e. 3.x) the default is to disable daemon but it may have been edited by your package. Also be sure you didn't install with an upstart script that will respawn.

Redis config file section

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

Example Supervisor configs

  • https://gist.github.com/ehazlett/1817619
  • https://github.com/calvdee/docker-redis/blob/master/supervisord.conf

Problem

redis-server is not working with below supervisord.conf

Especially, redis-server command with conf file location argument

redis-server --version

Redis server v=2.8.17 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=5b70b85861dcf95e

supervisord.conf

[program:redis-server]
command=redis-server /etc/redis/redis.conf # PLEASE NOTE THIS LINE
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/redis/stdout.log
stderr_logfile=/var/log/redis/stderr.log

my_redis.conf

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no

Dockerfile

RUN cp -f my_redis.conf /etc/redis/redis.conf &&\

supervisorctl

supervisorctl status

Test via command line

enter image description here

Solution

Without custom conf file location, everything works well.

In my case, I overwrote default conf in /etc/redis/redis.conf with my_redis.conf

[program:redis-server]
command=redis-server # JUST REMOVE EXTRA CONF FILE LOCATION, EVERYTHING WORKS WELL
autostart=true
autorestart=true
user=root
stdout_logfile=/var/log/redis/stdout.log
stderr_logfile=/var/log/redis/stderr.log

ps. Is there bug at this redis version? or my conf is wrong?