How to properly manage rabbitmq with supervisord

user316054 picture user316054 · Oct 11, 2011 · Viewed 14.8k times · Source

The current section in my supervisord.conf looks like:

[program:rabbitmq] command=/usr/sbin/rabbitmq-server

When I try to stop the rabbitmq with supervisord ( supervisorctl stop rabbitmq), the rabbitmq processes simply do not shut down. The rabbitmq documentation also mentions to never use kill but rather use rabbitmqctl stop . I'm guessing supervisord simply kills the processes - hence the poor results with rabbitmq. I couldn't find any options in supervisord to specify a custom stop command.

Do you have any recommendations?

Answer

Hui Zheng picture Hui Zheng · Mar 21, 2012

My solution is to write a wrapper script named rabbitmq.sh as follows:

# call "rabbitmqctl stop" when exiting
trap "{ echo Stopping rabbitmq; rabbitmqctl stop; exit 0; }" EXIT

echo Starting rabbitmq
rabbitmq-server

After that, modify supervisord.conf:

[program:rabbitmq]
command=path/to/rabbitmq.sh