Hi!
I’m facing an issue and can’t find a working solution.
I have Sanic running via Supervisor, with the following configuration file:
[program:project]
user = me
command=/var/www/project/env/bin/python /var/www/project/www/server.py --prod
autostart=true
autorestart=true
stopsignal=INT
startsecs=2
stopwaitsecs=5
(I also tried with stopsignal=TERM
)
Here’s the logs in supervisor:
[2023-03-23 10:11:01 +0000] [2124160] [INFO] Received signal SIGTERM. Shutting down.
[2023-03-23 10:11:01 +0000] [2124160] [INFO] Server Stopped
[2023-03-23 10:11:01 +0000] [2124186] [INFO] Stopping worker [2124186]
[2023-03-23 10:11:01 +0000] [2124185] [INFO] Stopping worker [2124185]
But then, nothing happen. It never start again.
Looking at the process, there are still three process running and never stopping:
[email protected]:~$ ps aux | grep python | grep mult
user 2125387 0.0 0.1 14808 11016 ? S 10:12 0:00 /var/www/project/env/bin/python -c from multiprocessing.resource_tracker import main;main(15)
user 2125388 0.0 0.4 44892 28592 ? S 10:12 0:00 /var/www/project/env/bin/python -c from multiprocessing.spawn import spawn_main; spawn_main(tracker_fd=16, pipe_handle=18) --multiprocessing-fork
user 2125389 0.3 0.3 43528 26360 ? S 10:12 0:00 /var/www/project/env/bin/python -c from multiprocessing.spawn import spawn_main; spawn_main(tracker_fd=16, pipe_handle=20) --multiprocessing-fork
I have to kill -9
them in order to have the server really restart.
Why?
How can I tell Sanic to properly restart?
Running the same above Sanic code in dev mode (debug=true), it handles requests properly, and once I hit CTRL+C
, it properly stops process, waits for the requests to finish, then fully stop the instance.
Looking on the web, CTRL+C
is the equivalent of SIGINT, but for some reason, when not in debug, Sanic ignores the SIGINT signal.
I’d like a way to properly restart Sanic while waiting for the current requests to finish first. How can I do that?
Thanks in advance!