Closed dxps closed 5 months ago
The watchexec
way works like this:
❯ watchexec --exts rs --restart -- cargo run --bin server -- --port 9091 --log debug
[Running: cargo run --bin server -- --port 9091 --log debug]
Finished dev [unoptimized + debuginfo] target(s) in 0.09s
Running `target/debug/server --port 9091 --log debug`
2024-02-10T19:15:42.006302Z INFO server: The server is starting up (pid 300564) ...
2024-02-10T19:15:42.006400Z INFO server: Listening for requests on http://[::1]:9091 ...
2024-02-10T19:15:53.488047Z INFO server: Shutting down gracefully ...
[Running: cargo run --bin server -- --port 9091 --log debug]
...
While the server can gracefully shutdown if it receives the expected signal,
cargo-watch
does not have an option to specify which signal to send to the running (server) process, nor wait for it to shutdown (see this).The alternative is to use watchexec.