From 85406daa9a658956d77d4506322a1c2456f1c4e1 Mon Sep 17 00:00:00 2001 From: xeor Date: Fri, 12 Dec 2014 13:22:42 +0100 Subject: [PATCH 1/2] Fix #10 --- bin/rabbitmq-start | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/rabbitmq-start b/bin/rabbitmq-start index 20853f0..ec4ed3d 100644 --- a/bin/rabbitmq-start +++ b/bin/rabbitmq-start @@ -1,5 +1,16 @@ #!/bin/bash +# rabbitmq-server is in itself a shell script that doesnt +# use exec (ie, it wont replace init 1 with rabbitmq itself). +# Docker sends its stop signal to the containers init 1, which +# wont reach rabbitmq. This ends up timing out on the Docker-side +# for default 10 seconds, till we (the container) is getting killed. +# We need to trap SIGTERM to handle this. +PID=; trap '[[ ${PID} ]] && /usr/sbin/rabbitmqctl stop; exit 0' SIGTERM + ulimit -n 1024 chown -R rabbitmq:rabbitmq /data -exec rabbitmq-server $@ +rabbitmq-server $@ & PID=$! + +# Dont exit this script since we would loose our SIGTERM trap +wait From fe516e11d04909fa703655360f39cdb44b7c4eee Mon Sep 17 00:00:00 2001 From: xeor Date: Tue, 6 Jan 2015 12:07:43 +0100 Subject: [PATCH 2/2] Trapping SIGINT as well To support ^c inside the container. --- bin/rabbitmq-start | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/rabbitmq-start b/bin/rabbitmq-start index ec4ed3d..5f58807 100644 --- a/bin/rabbitmq-start +++ b/bin/rabbitmq-start @@ -6,7 +6,7 @@ # wont reach rabbitmq. This ends up timing out on the Docker-side # for default 10 seconds, till we (the container) is getting killed. # We need to trap SIGTERM to handle this. -PID=; trap '[[ ${PID} ]] && /usr/sbin/rabbitmqctl stop; exit 0' SIGTERM +PID=; trap '[[ ${PID} ]] && /usr/sbin/rabbitmqctl stop; exit 0' SIGTERM SIGINT ulimit -n 1024 chown -R rabbitmq:rabbitmq /data