Discussion:
[Supervisor-users] Controlling a process that has its own subprocess
Carlos Konstanski
2017-06-09 21:37:01 UTC
Permalink
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
David Birdsong
2017-06-09 21:49:20 UTC
Permalink
On Fri, Jun 9, 2017 at 2:37 PM, Carlos Konstanski <
Post by 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.
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,
Post by Carlos Konstanski
Carlos Konstanski
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Carlos Konstanski
2017-06-09 21:56:58 UTC
Permalink
Post by David Birdsong
On Fri, Jun 9, 2017 at 2:37 PM, Carlos Konstanski <
Post by 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.
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.

Nils Toedtmann
2017-06-09 21:50:05 UTC
Permalink
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
Post by 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
https://lists.supervisord.org/mailman/listinfo/supervisor-users
--
Nils Toedtmann, Systems Architect & Director
***@demandlogic.co.uk
+44 (0) 7821 817722
_
Demand Logic Limited office:
Here East, Queen Elizabeth Olympic Park, London E20 3BS, UK
http://www.demandlogic.co.uk/
***@demandlogic.co.uk
+44 (0) 20 7193 4212
Loading...