I tried asking this question a few weeks ago, but included too many unnecessary details about what I am doing. This is my attempt to see if narrowing the question can get me some useful feedback.
I am running a number of servers via fastapi and uvicorn, and in many cases using the @app.on_event("shutdown")
decorator for some code which should automatically run when the server is shut down. Initially, I was calling each of these servers in its own terminal, and pressing ctrl-c in that terminal was sufficient to reliably shut down the server and call the shutdown code. However, that is no longer practical for me to do, and so I am wondering, what other signals or procedures can be used to trigger the code under @app.on_event("shutdown")
in fastapi with uvicorn. So far, I have confirmed that sending terminate or kill signals to the uvicorn process do not cause that code to be triggered on shutdown, and I am not sure what else would do the job. So, for other users of fastapi and uvicorn, what other than ctrl-c do you use to kill your servers?