-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: gracefully shutdown command when shutdown signal is received #493
base: main
Are you sure you want to change the base?
Changes from 12 commits
28bb5d3
c183d2a
8af1906
774a479
e46c198
df8d0a5
89d1e96
cd79bd2
3a53451
a02b36e
a322361
677e345
cc78c84
d25db97
aeaa5b5
91c343e
1cf5b08
477bfd2
2841ad1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
use miette::{IntoDiagnostic, Result}; | ||
use std::path::Path; | ||
use std::sync::Arc; | ||
use watchexec_supervisor::command::{Command, Program}; | ||
|
||
use miette::{IntoDiagnostic, Result}; | ||
use watchexec::Watchexec; | ||
use watchexec_signals::Signal; | ||
use watchexec_supervisor::command::{Command, Program}; | ||
use watchexec_supervisor::job::{start_job, Job}; | ||
|
||
use crate::mode::Mode; | ||
|
@@ -21,7 +20,6 @@ const DEV_SSR_BIN_SRC: &str = "node_modules\\.bin\\tuono-dev-ssr.cmd"; | |
const DEV_WATCH_BIN_SRC: &str = "node_modules/.bin/tuono-dev-watch"; | ||
#[cfg(not(target_os = "windows"))] | ||
const DEV_SSR_BIN_SRC: &str = "node_modules/.bin/tuono-dev-ssr"; | ||
|
||
fn watch_react_src() -> Job { | ||
if !Path::new(DEV_SSR_BIN_SRC).exists() { | ||
eprintln!("Failed to find script to run dev watch. Please run `npm install`"); | ||
|
@@ -129,9 +127,10 @@ pub async fn watch() -> Result<()> { | |
build_ssr_bundle.start(); | ||
} | ||
|
||
// if Ctrl-C is received, quit | ||
if action.signals().any(|sig| sig == Signal::Interrupt) { | ||
action.quit(); | ||
rust_server.delete(); | ||
build_ssr_bundle.delete(); | ||
action.quit_gracefully(Signal::Interrupt, std::time::Duration::from_secs(9999)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this automatically stops all the jobs? https://docs.rs/watchexec/latest/watchexec/action/struct.ActionHandler.html#method.quit_gracefully There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should have a shorter delay maybe like ~30s. |
||
} | ||
|
||
action | ||
|
@@ -141,5 +140,6 @@ pub async fn watch() -> Result<()> { | |
wx.config.pathset(["./src"]); | ||
|
||
let _ = wx.main().await.into_diagnostic()?; | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this new line back in