SIGTERM

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SIGTERM

carlhoerberg
Will RabbitMQ respond well to SIGTERM? Would like to replace the init.d script with a upstart script but not sure if rabbitmq will gracefully stop with a SIGTERM to the rabbitmq-server script? Or should I put "rabbitmqctl stop" as a "pre-stop" exec?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Tim Watson-6
Hi,

On 25 Mar 2013, at 14:29, carlhoerberg wrote:
> Will RabbitMQ respond well to SIGTERM?

I would say probably not, or at least, not 'well' anyway.

> Would like to replace the init.d
> script with a upstart script but not sure if rabbitmq will gracefully stop
> with a SIGTERM to the rabbitmq-server script? Or should I put "rabbitmqctl
> stop" as a "pre-stop" exec?
>

I would strongly advise using `rabbitmqctl stop` instead of using SIGTERM.

>
>
> --
> View this message in context: http://rabbitmq.1065348.n5.nabble.com/SIGTERM-tp25695.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> [hidden email]
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Simon MacMullen-2
On 25/03/13 15:06, Tim Watson wrote:
>> >Would like to replace the init.d
>> >script with a upstart script but not sure if rabbitmq will gracefully stop
>> >with a SIGTERM to the rabbitmq-server script? Or should I put "rabbitmqctl
>> >stop" as a "pre-stop" exec?
>> >
> I would strongly advise using `rabbitmqctl stop` instead of using SIGTERM.
>

Note in particular that "rabbitmqctl stop <pidfile>" will ensure that by
the time the rabbitmqctl invocation exits then the RabbitMQ server will
have shut down and the VM will have closed. SIGTERM would not give you
that even if we trapped it (and it's not obvious Erlang lets you do that...)

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

carlhoerberg
Ok, thanks. This is how my upstart script looks now:

description "RabbitMQ Server"

start on runlevel [2345]
stop on runlevel [016]
kill timeout 60
respawn
respawn limit 10 5
console log
setuid rabbitmq
setgid rabbitmq
env HOME=/var/lib/rabbitmq

exec /usr/lib/rabbitmq/bin/rabbitmq-server
post-start exec /usr/sbin/rabbitmqctl wait
pre-stop exec /usr/sbin/rabbitmqctl stop
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Tim Watson-6
Hi

On 26 Mar 2013, at 05:25, carlhoerberg wrote:
> exec /usr/lib/rabbitmq/bin/rabbitmq-server
> post-start exec /usr/sbin/rabbitmqctl wait
> pre-stop exec /usr/sbin/rabbitmqctl stop
>

The rabbitmqctl wait command takes the pid file as an argument. So this might not be as simple as it sounds.

>
>
>
> --
> View this message in context: http://rabbitmq.1065348.n5.nabble.com/SIGTERM-tp25695p25712.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> [hidden email]
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Simon MacMullen-2
On 26/03/13 12:16, Tim Watson wrote:

> Hi
>
> On 26 Mar 2013, at 05:25, carlhoerberg wrote:
>> exec /usr/lib/rabbitmq/bin/rabbitmq-server
>> post-start exec /usr/sbin/rabbitmqctl wait
>> pre-stop exec /usr/sbin/rabbitmqctl stop
>>
>
> The rabbitmqctl wait command takes the pid file as an argument. So
> this might not be as simple as it sounds.

Although if you are using the debian packages as a starting point, the
pid file is just /var/run/rabbitmq/pid, so it's not much less simple.

Note that you are also running as root. So I would modify two lines:

post-start exec /usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid
pre-stop exec /usr/sbin/rabbitmqctl stop /var/run/rabbitmq/pid

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Simon MacMullen-2
On 26/03/13 12:25, Simon MacMullen wrote:
> post-start exec /usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid
> pre-stop exec /usr/sbin/rabbitmqctl stop /var/run/rabbitmq/pid

Oh, and:

env PID_FILE=/var/run/rabbitmq/pid

I forgot the existing init script sets that.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Tim Watson-6
In reply to this post by Simon MacMullen-2
On 26 Mar 2013, at 12:25, Simon MacMullen wrote:
> Note that you are also running as root. So I would modify two lines:
>
> post-start exec /usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid
> pre-stop exec /usr/sbin/rabbitmqctl stop /var/run/rabbitmq/pid
>

Doesn't the previous setuid/setgid deal with that?

> Cheers, Simon
>
> --
> Simon MacMullen
> RabbitMQ, VMware

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

Simon MacMullen-2
On 26/03/13 13:09, Tim Watson wrote:
> On 26 Mar 2013, at 12:25, Simon MacMullen wrote:
>> Note that you are also running as root. So I would modify two lines:
>>
>> post-start exec /usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid
>> pre-stop exec /usr/sbin/rabbitmqctl stop /var/run/rabbitmq/pid
>>
>
> Doesn't the previous setuid/setgid deal with that?

Argh; I wrote the "Note that" before noticing the setuid/setgid, then
failed to delete it. Please ignore.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SIGTERM

carlhoerberg
Yes, $PID_FILE and "normal exit 0" was important, without "normal exit" the process would be respawned as soon as it was stopped in pre-stop.  

description "RabbitMQ Server"
start on runlevel [2345]
stop on runlevel [016]
kill timeout 60
respawn
respawn limit 10 5
normal exit 0
console log
setuid rabbitmq
setgid rabbitmq
env HOME=/var/lib/rabbitmq
env PID_FILE=/var/run/rabbitmq/pid
exec /usr/lib/rabbitmq/bin/rabbitmq-server
post-start exec /usr/sbin/rabbitmqctl wait $PID_FILE
pre-stop exec /usr/sbin/rabbitmqctl stop $PID_FILE


Thanks!  


On Tuesday 26 March 2013 at 21:15, Simon MacMullen-2 [via RabbitMQ] wrote:

> On 26/03/13 13:09, Tim Watson wrote:
> > On 26 Mar 2013, at 12:25, Simon MacMullen wrote:
> > > Note that you are also running as root. So I would modify two lines:
> > >
> > > post-start exec /usr/sbin/rabbitmqctl wait /var/run/rabbitmq/pid
> > > pre-stop exec /usr/sbin/rabbitmqctl stop /var/run/rabbitmq/pid
> >
> >
> > Doesn't the previous setuid/setgid deal with that?
>
> Argh; I wrote the "Note that" before noticing the setuid/setgid, then
> failed to delete it. Please ignore.
>
> Cheers, Simon
>
> --
> Simon MacMullen
> RabbitMQ, VMware
> _______________________________________________
> rabbitmq-discuss mailing list
> [hidden email] (/user/SendEmail.jtp?type=node&node=25728&i=0)
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
> If you reply to this email, your message will be added to the discussion below: http://rabbitmq.1065348.n5.nabble.com/SIGTERM-tp25695p25728.html 
> To unsubscribe from SIGTERM, click here (
> NAML (
http://rabbitmq.1065348.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml)



Loading...