[Supervisor-users] Controlling a process that has its own subprocess

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Supervisor-users] Controlling a process that has its own subprocess

Carlos Konstanski
I have a python process that I launch via a wrapper script. The wrapper
is responsible for ensuring that the virtualenv exists, that all the
packages in requirements.txt are installed, that the virtualenv is
activated, and finally it launches the python program.

When I run it under supervisord, the wrapper script is the process that
is being managed. The actual python program is a child-of-a-child and
supervisord knows nothing about it.

I performed the following experiment: I killed the wrapper script. The
result was that the child python process kept running but was now a
child of init (a top-level process). supervisord relaunched the wrapper
script. Now I had two python processes running.

How can I get supervisord to have knowledge of both the wrapper script
and its children? Alternatively, I wonder if there's a way to make my
python program die if the wrapper script dies. That would be just as
good.

Thanks,
Carlos Konstanski
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] Controlling a process that has its own subprocess

David Birdsong


On Fri, Jun 9, 2017 at 2:37 PM, Carlos Konstanski <[hidden email]> wrote:
I have a python process that I launch via a wrapper script. The wrapper
is responsible for ensuring that the virtualenv exists, that all the
packages in requirements.txt are installed, that the virtualenv is
activated, and finally it launches the python program.

When I run it under supervisord, the wrapper script is the process that
is being managed. The actual python program is a child-of-a-child and
supervisord knows nothing about it.

I performed the following experiment: I killed the wrapper script. The
result was that the child python process kept running but was now a
child of init (a top-level process). supervisord relaunched the wrapper
script. Now I had two python processes running.

How can I get supervisord to have knowledge of both the wrapper script
and its children? Alternatively, I wonder if there's a way to make my
python program die if the wrapper script dies. That would be just as
good.


it doesn't sound like the wrapper script needs to do anything after it's startup and after the sub-proc runs. if that's the case, just exec into the final script. the parent/child relationship between supervisor and your desired child proc will be maintained.

Thanks,
Carlos Konstanski
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users


_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] Controlling a process that has its own subprocess

Nils Toedtmann
In reply to this post by Carlos Konstanski
If your wrapper is a bash script, you could try to call your python
program via bash's "exec", which will replace the former with the latter
without spawning a new process. See e.g.

  http://wiki.bash-hackers.org/commands/builtin/exec

/n


On 09/06/17 22:37, Carlos Konstanski wrote:

> I have a python process that I launch via a wrapper script. The wrapper
> is responsible for ensuring that the virtualenv exists, that all the
> packages in requirements.txt are installed, that the virtualenv is
> activated, and finally it launches the python program.
>
> When I run it under supervisord, the wrapper script is the process that
> is being managed. The actual python program is a child-of-a-child and
> supervisord knows nothing about it.
>
> I performed the following experiment: I killed the wrapper script. The
> result was that the child python process kept running but was now a
> child of init (a top-level process). supervisord relaunched the wrapper
> script. Now I had two python processes running.
>
> How can I get supervisord to have knowledge of both the wrapper script
> and its children? Alternatively, I wonder if there's a way to make my
> python program die if the wrapper script dies. That would be just as
> good.
>
> Thanks,
> Carlos Konstanski
> _______________________________________________
> Supervisor-users mailing list
> [hidden email]
> https://lists.supervisord.org/mailman/listinfo/supervisor-users
>


--
Nils Toedtmann, Systems Architect & Director
[hidden email]
+44 (0) 7821 817722
_
Demand Logic Limited office:
Here East, Queen Elizabeth Olympic Park, London E20 3BS, UK
http://www.demandlogic.co.uk/
[hidden email]
+44 (0) 20 7193 4212
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] Controlling a process that has its own subprocess

Carlos Konstanski
In reply to this post by David Birdsong
> On Fri, Jun 9, 2017 at 2:37 PM, Carlos Konstanski <
> [hidden email]> wrote:
>
>> I have a python process that I launch via a wrapper script. The wrapper
>> is responsible for ensuring that the virtualenv exists, that all the
>> packages in requirements.txt are installed, that the virtualenv is
>> activated, and finally it launches the python program.
>>
>> When I run it under supervisord, the wrapper script is the process that
>> is being managed. The actual python program is a child-of-a-child and
>> supervisord knows nothing about it.
>>
>> I performed the following experiment: I killed the wrapper script. The
>> result was that the child python process kept running but was now a
>> child of init (a top-level process). supervisord relaunched the wrapper
>> script. Now I had two python processes running.
>>
>> How can I get supervisord to have knowledge of both the wrapper script
>> and its children? Alternatively, I wonder if there's a way to make my
>> python program die if the wrapper script dies. That would be just as
>> good.
>>
>>
> it doesn't sound like the wrapper script needs to do anything after it's
> startup and after the sub-proc runs. if that's the case, just exec into the
> final script. the parent/child relationship between supervisor and your
> desired child proc will be maintained.
>
That is the hot ticket! Thanks so much. The wrapper script disappers
from ps entirely.
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users