Discussion:
[Supervisor-users] supervisorctl stop does not stop gunicorn running inside a schroot session
Ingo Fischer
2014-11-30 12:17:07 UTC
Permalink
Hi all!

I'm running a Gunicorn server inside a schroot
<https://wiki.debian.org/Schroot> session via supervisor. My problem is
that the service is not fully stopped when stopping it with
"supervisorctl stop".

This is the script (simplified) controlling my server, it opens a
schroot session and runs gunicorn in it, in foreground:

#/bin/sh
# gunicorn.sh
schroot -c gunicorn -r -- bash -c "gunicorn --workers=1
myapp.wsgi:application"

This is my supervisor config to run this script:

# gunicorn.conf
[program:gunicorn]
command=/home/test/gunicorn.sh
stderr_logfile=/var/log/gunicorn.err.log
stdout_logfile=/var/log/gunicorn.out.log

When I start the service via "supervisorctl start" , my process tree
looks like this:

init(1)-supervisord(7175)---gunicorn.sh(8061)---schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)

Now when I stop the service with "supervisorctl stop", The corresponding
supervisor process and its direct child, gunicorn.sh, are terminated.
But the schroot process itself continues to live and is now a child of
the init process:

init(1)-schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)

This whole behavior might be related to the way schroot works.
But what I do not understand is that Supervisor config says that as long
as a process runs in foreground and stays attached to the console,
supervisor should be able to start/stop it. And I believe that this is
how my schroot-process behaves.
But still supervisor seems unable to stop the process.

What can I do to stop the gunicorn process correctly with supervisorctl
stop?

Thanks in advance!
Cheers, Ingo
Gustavo Carneiro
2014-11-30 12:27:16 UTC
Permalink
Post by Ingo Fischer
Hi all!
I'm running a Gunicorn server inside a schroot
<https://wiki.debian.org/Schroot> session via supervisor. My problem is
that the service is not fully stopped when stopping it with "supervisorctl
stop".
This is the script (simplified) controlling my server, it opens a schroot
#/bin/sh
# gunicorn.sh
schroot -c gunicorn -r -- bash -c "gunicorn --workers=1
myapp.wsgi:application"
Maybe it helps to put exec in front of gunicorn?
schroot -c gunicorn -r -- bash -c "exec gunicorn --workers=1
myapp.wsgi:application"
Post by Ingo Fischer
# gunicorn.conf
[program:gunicorn]
command=/home/test/gunicorn.sh
stderr_logfile=/var/log/gunicorn.err.log
stdout_logfile=/var/log/gunicorn.out.log
When I start the service via "supervisorctl start" , my process tree looks
init(1)-supervisord(7175)---gunicorn.sh(8061)---schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)
Now when I stop the service with "supervisorctl stop", The corresponding
supervisor process and its direct child, gunicorn.sh, are terminated.
But the schroot process itself continues to live and is now a child of the
init(1)-schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)
This whole behavior might be related to the way schroot works.
But what I do not understand is that Supervisor config says that as long
as a process runs in foreground and stays attached to the console,
supervisor should be able to start/stop it. And I believe that this is how
my schroot-process behaves.
But still supervisor seems unable to stop the process.
What can I do to stop the gunicorn process correctly with supervisorctl
stop?
Thanks in advance!
Cheers, Ingo
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
--
Gustavo J. A. M. Carneiro
Gambit Research
"The universe is always one step beyond logic." -- Frank Herbert
Ingo Fischer
2014-11-30 13:53:52 UTC
Permalink
Post by Ingo Fischer
Hi all!
I'm running a Gunicorn server inside a schroot
<https://wiki.debian.org/Schroot> session via supervisor. My
problem is that the service is not fully stopped when stopping it
with "supervisorctl stop".
This is the script (simplified) controlling my server, it opens a
#/bin/sh
# gunicorn.sh
schroot -c gunicorn -r -- bash -c "gunicorn --workers=1
myapp.wsgi:application"
Maybe it helps to put exec in front of gunicorn?
I'm pretty sure I tried using exec in various combinations with no
success before...
Now I tried again and suddenly it works, all gunicorn child processes
are gone when I call the stop-command.

Indeed using exec seems to be the solution to the problem. Thank you,
Gustavo!
Post by Ingo Fischer
schroot -c gunicorn -r -- bash -c "exec gunicorn --workers=1
myapp.wsgi:application"
# gunicorn.conf
[program:gunicorn]
command=/home/test/gunicorn.sh
stderr_logfile=/var/log/gunicorn.err.log
stdout_logfile=/var/log/gunicorn.out.log
When I start the service via "supervisorctl start" , my process
init(1)-supervisord(7175)---gunicorn.sh(8061)---schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)
Now when I stop the service with "supervisorctl stop", The
corresponding supervisor process and its direct child,
gunicorn.sh, are terminated.
But the schroot process itself continues to live and is now a
init(1)-schroot(8067)---gunicorn(8068)---gunicorn(8073)---{gunicorn}(8078)
This whole behavior might be related to the way schroot works.
But what I do not understand is that Supervisor config says that
as long as a process runs in foreground and stays attached to the
console, supervisor should be able to start/stop it. And I believe
that this is how my schroot-process behaves.
But still supervisor seems unable to stop the process.
What can I do to stop the gunicorn process correctly with
supervisorctl stop?
Thanks in advance!
Cheers, Ingo
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
--
Gustavo J. A. M. Carneiro
Gambit Research
"The universe is always one step beyond logic." -- Frank Herbert
Loading...