feat: add serve-shutdown support
This commit is contained in:
1 parent
f47d2d3d30
commit
20c29ed042
4 files changed
+35
-9
No files matched your search
Generated
+23
@@ -502,6 +502,16 @@ dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctrlc"
|
||||
version = "3.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173"
|
||||
dependencies = [
|
||||
"nix",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curl"
|
||||
version = "0.4.44"
|
||||
@@ -610,6 +620,7 @@ dependencies = [
|
||||
"clap",
|
||||
"colored 2.0.0",
|
||||
"convert_case",
|
||||
"ctrlc",
|
||||
"dioxus",
|
||||
"dioxus-rsx-interpreter",
|
||||
"dirs 4.0.0",
|
||||
@@ -1621,6 +1632,18 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.25.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "5.0.0-pre.16"
|
||||
|
||||
+2
-1
@@ -58,10 +58,11 @@ dioxus = { git = "https://github.com/dioxuslabs/dioxus/", features = ["hot-reloa
|
||||
dioxus-rsx-interpreter = { git = "https://github.com/dioxuslabs/dioxus/" }
|
||||
|
||||
proc-macro2 = { version = "1.0", features = ["span-locations"] }
|
||||
lazy_static = "1.4.0"
|
||||
|
||||
# plugin packages
|
||||
mlua = { version = "0.8.1", features = ["lua54", "vendored", "async", "send"] }
|
||||
lazy_static = "1.4.0"
|
||||
ctrlc = "3.2.3"
|
||||
|
||||
[[bin]]
|
||||
path = "src/main.rs"
|
||||
|
||||
@@ -11,6 +11,7 @@ async fn main() -> Result<()> {
|
||||
available: true,
|
||||
required: vec![],
|
||||
});
|
||||
|
||||
if !plugin_state {
|
||||
log::error!("🚫 Plugin system initialization failed");
|
||||
exit(1);
|
||||
|
||||
+9
-8
@@ -53,6 +53,13 @@ struct WsReloadState {
|
||||
}
|
||||
|
||||
pub async fn startup(port: u16, config: CrateConfig) -> Result<()> {
|
||||
// ctrl-c shutdown checker
|
||||
let crate_config = config.clone();
|
||||
let _ = ctrlc::set_handler(move || {
|
||||
let _ = PluginManager::on_serve_shutdown(&crate_config);
|
||||
std::process::exit(0);
|
||||
});
|
||||
|
||||
if config.hot_reload {
|
||||
startup_hot_reload(port, config).await?
|
||||
} else {
|
||||
@@ -61,10 +68,7 @@ pub async fn startup(port: u16, config: CrateConfig) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn startup_hot_reload(
|
||||
port: u16,
|
||||
config: CrateConfig,
|
||||
) -> Result<()> {
|
||||
pub async fn startup_hot_reload(port: u16, config: CrateConfig) -> Result<()> {
|
||||
let first_build_result = crate::builder::build(&config, false)?;
|
||||
|
||||
log::info!("🚀 Starting development server...");
|
||||
@@ -279,10 +283,7 @@ pub async fn startup_hot_reload(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn startup_default(
|
||||
port: u16,
|
||||
config: CrateConfig,
|
||||
) -> Result<()> {
|
||||
pub async fn startup_default(port: u16, config: CrateConfig) -> Result<()> {
|
||||
let first_build_result = crate::builder::build(&config, false)?;
|
||||
|
||||
log::info!("🚀 Starting development server...");
|
||||
|
||||
Reference in new issue
Block a user