zeke-io / crafty

Make your minecraft servers VCS friendly!
MIT License
0 stars 0 forks source link

Proper `Ctrl+C`/`SIGINT` handling #23

Open zeke-io opened 1 year ago

zeke-io commented 1 year ago

Describe the bug

Currently there is no proper "graceful shutdown"/"cleanup" process, the server is executed using the tokio's process::Command.

https://github.com/zeke-io/chain/blob/81ce70eb35c5666d89932c3c6c17ba23e7ce09c9/crates/chain/src/runtime.rs#L85-L100

When stopping the server with CTRL+C/SIGINT, Chain immediately quits but the server process is still running gracefully shuttind down.

Expected behavior

Whether the server stops via a stop command or the CTRL+C/SIGINT signal, Chain should always wait for the server process to go through its shutdown process first before exiting.

Steps to reproduce

  1. Create a server project
  2. Run the server with chain run
  3. Press CTRL+C to quit