restart workers online (graceful restart) to hot reload, in production environment.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe.
Condition: keep service available any time.
---- client code----
async def run():
while 1:
await post('http://127.0.0.1:8000/')
when called app.m.restart(“ALL_PROCESSES”) in a worker, sanic crashed.
---- server code ----
@app.post("/")
async def handler(request):
app.m.restart('__ALL_PROCESSES__')
return response.text('ok')
if __name__ == "__main__":
app.run(debug=True, workers=2)
Describe the solution you’d like
graceful restarting and reduce the effect when restarting. my messy describe:
- graceful restart workers; restart all workers will not crash, if only 1 worker, block a little while (if worker not started yet) is ok.
- a way to graceful restart worker one by one, code eg: woker_names = tuple(app.m.workers.keys()) for woker_name in worker_names: ret_val = app.m.restart(worker_name) # here, the worker has been graceful restarted, ret_val is meaningful
- may combine the above 2, when restarting all workers, 50% workers restarting, 50% old workers keep serving
Additional context
simplify the api,
app.m.restart('__ALL_PROCESSES__') => app.m.restart_all()
thanks.
Issue Analytics
- State:
- Created 9 months ago
- Comments:17 (12 by maintainers)
Top Results From Across the Web
The Art of Graceful Reloading — uWSGI 2.0 documentation
Requires --lazy-apps option. To trigger it: ... It will wait for running workers and then restart each of them. Pros: ... Cons: no...
Read more >Gracefully Restart Nginx Web Server After Config Update
QUIT : Graceful shutdown; KILL : Halts a stubborn process; HUP : Configuration reload. Start the new worker processes with a new configuration....
Read more >Settings — Gunicorn 20.1.0 documentation
reload. Restart workers when code changes. This setting is intended for development. It will cause workers to be restarted whenever application code changes....
Read more >How to correctly reset, restart, and recycle IIS websites
Start sending NEW requests to the new worker process. Tell the current worker process process to shut down, finishing out any existing requests...
Read more >puma/restart.md at master - GitHub
Phased restarts replace all running workers in a Puma cluster. This is a useful way to upgrade the application that Puma is serving...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s okay to do a good job of HTTP link processing with short responses, and the same is true for my personal needs. Restarting the main process, modifying the IP address and port is not considered. For some long-term services, such as websockets, streams, etc., they can be handled by sanic user, including but not limited to deliberately increasing the waiting time for graceful closing. Otherwise, the sanic becomes too complex and even brings more bugs, which is not friendly to the majority of users.
amazing! thats it