[rabbitmq-discuss] "service rabbitmq-server start" hangs when using python's Popen from subprocess.

Raphaël De GIUSTI raphael.degiusti at guardis.com
Tue Oct 16 14:25:27 BST 2012


It seems that the following line in /etc/init.d/rabbitmq-server script is
the cause of the Popen hang

        setsid sh -c "RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \
>             ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err" &


If I modify the script so it does not use setsid sh -c, the subprocess call
does not hang anymore, but I expect side-effects if I do this.

        RABBITMQ_PID_FILE=$PID_FILE $DAEMON > \
>             ${INIT_LOG_DIR}/startup_log 2> ${INIT_LOG_DIR}/startup_err &


Any idea on how to fix it with my python Popen method ?

On Tue, Oct 16, 2012 at 2:15 PM, Raphaël De GIUSTI <
raphael.degiusti at guardis.com> wrote:

> Well, I have the same problem when subprocessing
> "/etc/init.d/rabbitmq-server start".
>
> Note that I have no problem subprocessing "service rabbitmq-server status"
> or "service rabbitmq-server stop" (or any other service).
>
> My only issue is with the start method of /etc/init.d/rabbitmq-server init
> script.
>
>
>
>
> On Tue, Oct 16, 2012 at 1:34 PM, Tim Watson <tim at rabbitmq.com> wrote:
>
>> When you run RabbitMQ on an rpm based distro using /sbin/service then the
>> init script is going to redirect stdio, as you would expect for a
>> service/daemon. You'll need to start RabbitMQ directly from the
>> ./scripts/rabbitmq-server shell script I guess, if you want to grab stdio -
>> or tail the logs?
>>
>> On 16 Oct 2012, at 11:47, Raphaël De GIUSTI wrote:
>>
>> > Hi everyone,
>> >
>> > Starting the rabbitmq-server service with python's Popen from
>> subprocess makes it hang.
>> >
>> > Here's the little snippet to reproduce it (tested on Fedora 16 +
>> Python2.7 and Centos 6.3 + Python2.6)
>> >
>> > from subprocess import PIPE, Popen
>> > proc = Popen('service rabbitmq-server start', shell=True, stderr=PIPE,
>> stdout=PIPE)
>> > print proc.communicate()
>> >
>> > Problem is with "stdout=PIPE", I think.
>> >
>> > The following snippet works, using proc.wait()
>> >
>> > from subprocess import PIPE, Popen
>> > proc = Popen('service rabbitmq-server start', shell=True, stderr=PIPE,
>> stdout=PIPE)
>> > print proc.wait()
>> >
>> > Any idea on how to fix it using proc.communicate() because I need
>> feedback from the "subprocess.PIPE" ?
>> >
>> > Thank you.
>> >
>> > Raphael
>> > _______________________________________________
>> > rabbitmq-discuss mailing list
>> > rabbitmq-discuss at lists.rabbitmq.com
>> > https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20121016/ae0f7c15/attachment.htm>


More information about the rabbitmq-discuss mailing list