Skip to content
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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/tuono/src/watch.rs
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;
Expand All @@ -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";

Copy link
Contributor

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

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`");
Expand Down Expand Up @@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have a shorter delay maybe like ~30s.

}

action
Expand All @@ -141,5 +140,6 @@ pub async fn watch() -> Result<()> {
wx.config.pathset(["./src"]);

let _ = wx.main().await.into_diagnostic()?;

Ok(())
}
Loading