New multiprocess manager
Summary
About https://github.com/encode/uvicorn/discussions/2164.
The multiprocess manager introduced by this PR includes process keep-alive and process hung detection. It also imitates gunicorn and uses hup, ttin, and ttou signals to control child processes.
Checklist
- [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
- [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
- [x] I've updated the documentation accordingly.
@abersheeran I'm fully available to move this forward. š
Pinging @ahopkins to review the initial steps since he offered helped on #2164. š
Ok. š
We can move forward with the checklist above š
I see what the PR is doing, but I somewhat fail to understand the why and the goals. Is the pinging the ultimate feature add here?
The goal is to not suggest people to use Gunicorn anymore.
Next I will submit tests and documentation. If anyone can help, please commit directly to the branch of this PR... This will be a long and painful process. /(ćoć)/~~
Also, if I press CTRL + C on uvicorn main:app --workers 2, it doesn't work as expected.
Also, if I press
CTRL + Conuvicorn main:app --workers 2, it doesn't work as expected.
Can you try the latest commit version? This should solve the problem.
I think the PID should be shown in the "uvicorn.access" logger (only when workers > 1).
Is it normal for the child processes to be alive after I kill the manager process?
I think the PID should be shown in the
"uvicorn.access"logger (only whenworkers > 1).
Here I just reused the previous logger. If we want to refactor the logs, I think it can be done in another PR.
Is it normal for the child processes to be alive after I kill the manager process?
No, normally only killing the manager process through the SIGKILL signal will result in the survival of child processes (this is due to system signal mechanism reasons, and it also exists in all other multi-process managers), under other circumstances, child processes should be killed.
Thanks @abersheeran š