Hi!
I noticed that when running the Sanic server, it seems to gracefully restart without killing the running requests (please correct me if I’m wrong).
Having a watcher for file changes ensure that a new instance is spawned, and made primary once the old one is stopped.
This is really nice and I tried looking through the code to find a way to call that “restart” part from an external code, but couldn’t find how to properly do that.
My issue is as follow:
When a push is done on Github, a (Python) script is run on my server. This script updates the code from the latest changes, upgrade the package and add new ones if any, then update the database (via alembic migration).
The issue is that right now, Sanic server is running using auto_reload=True
. When a git pull
is done, the server is restarted quickly, but if the new code contains a new package not yet installed, it fails.
What I would like to do is set auto_reload
to False, be able to do my local changes (git pull, updating packages and database) then calling restart
on Sanic like the auto_reload
would do.
How could I go on calling restart
on an already Sanic instance from an external script ?
Thanks in advance for your help!