Description
Is 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.