SIGTERM and SIGINT always shut down tokio runtime when using `#[actix::main]`
- Langage dominant
- Rust
- Étoiles
- 24.8k
- Forks
- 1.9k
- Merge moyen
- 23 h 10 min
- PR mergées (30 j)
- 26
Description
I have a project where I spawn some background tasks before starting the `HttpServer`, and when the server has stopped, I notify the tasks and join them, which means there is still some code running between the server shutdown and the program exit. However, when stopping the server with SIGINT (Ctrl+C) or SIGTERM (using kill), it immediatly shuts down Tokio, which results in errors like `error importing requests: Execution Error: error communicating with database: A Tokio 1.x context was found, but it is being shutdown.` from the background tasks. The only thing I found was `HttpServer::system_exit`, which is supposed to "[flag] the System to exit after server shutdown", however, in my case I don't call this function and the system shutdown still seems to happen. My current workaround for this is to use `#[tokio::main]` instead of `#[actix::main]`, but I think it would be nice to have the entire system not shutdown after the server stops.
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.