Skip to content

Instantly share code, notes, and snippets.

@joelwurtz
Created December 9, 2014 14:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelwurtz/4204217a1e304c11765d to your computer and use it in GitHub Desktop.
Save joelwurtz/4204217a1e304c11765d to your computer and use it in GitHub Desktop.
Rabbitmq as a service under docker (altmost right) :/
#!/bin/bash
chown -R rabbitmq:rabbitmq /data/log
chown -R rabbitmq:rabbitmq /data/mnesia
HOSTNAME=$(hostname)
PID_FILE="/data/mnesia/rabbit\@$HOSTNAME.pid"
function start()
{
su rabbitmq -s /bin/sh -c "/usr/lib/rabbitmq/bin/rabbitmq-server" &
su rabbitmq -s /bin/sh -c "/usr/sbin/rabbitmqctl wait $PID_FILE"
}
function stop()
{
su rabbitmq -s /bin/sh -c "/usr/sbin/rabbitmqctl stop $PID_FILE"
exit
}
function restart()
{
su rabbitmq -s /bin/sh -c "/usr/sbin/rabbitmqctl restart"
}
trap stop EXIT SIGINT SIGTERM
trap restart SIGHUP
start
while true; do
sleep 1000 & wait
done
@jleskovar
Copy link

This won't work if you explicitly set RABBITMQ_NODENAME, as the pid file will be named differently.
Otherwise looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment