How to properly manage rabbitmq with supervisord

rabbitmqsupervisord

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?

Best Answer

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 
Related Topic