start redis with supervisor

17k views Asked by At

When start redis with supervisor, the redis process is running, but in supervisor it shows backoff.

vagrant@jinming:~$ sudo supervisorctl -c /etc/conf/supervisor/supervisord.conf
redis                            BACKOFF   Exited too quickly (process log may have details)

in supervisor log, it shows below:

2015-06-09 07:09:28,407 CRIT Supervisor running as root (no user in config file)
2015-06-09 07:09:28,407 WARN Included extra file "/etc/conf/supervisor/conf.d/redis_local.conf" during parsing
2015-06-09 07:09:28,407 INFO RPC interface 'supervisor' initialized
2015-06-09 07:09:28,407 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-06-09 07:09:28,407 INFO supervisord started with pid 23191
2015-06-09 07:09:29,410 INFO spawned: 'redis' with pid 23332
2015-06-09 07:09:29,416 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:30,418 INFO spawned: 'redis' with pid 23334
2015-06-09 07:09:30,425 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:32,429 INFO spawned: 'redis' with pid 23336  
2015-06-09 07:09:32,434 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:36,067 INFO spawned: 'redis' with pid 23342
2015-06-09 07:09:36,072 INFO exited: redis (exit status 0; not expected)
2015-06-09 07:09:37,073 INFO gave up: redis entered FATAL state, too many start retries too quickly
2015-06-09 07:11:04,079 CRIT Supervisor running as root (no user in config file)
2015-06-09 07:11:04,079 WARN Included extra file "/etc/conf/supervisor/conf.d/redis_local.conf" during parsing
2015-06-09 07:11:04,080 INFO RPC interface 'supervisor' initialized
2015-06-09 07:11:04,080 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2015-06-09 07:11:04,080 INFO supervisord started with pid 23191
2015-06-09 07:11:05,083 INFO spawned: 'redis' with pid 23486
2015-06-09 07:11:05,089 INFO exited: redis (exit status 0; not expected)

anyone can help me, thanks.

2

There are 2 answers

2
Mike S. On BEST ANSWER

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

1
Jay Lim On

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?