From 168d48798dce835e8339861e24ba86afaaa632ca Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Mon, 5 Jul 2021 06:05:08 +0200 Subject: [PATCH] neard: handle SIGINT by stopping the node (#4449) Stop the system once a SIGINT is received. This should allow for graceful termination since System::stop will stop all the arbiters and that in turn will stop all the actors (leading them through stopping and stopped states thus allowing all the necessary cleanups). To achieve this, also update uptade wasmer-runtime-core dependency to 0.17.4. Among other things, the new version no longer catches the INT signal making it available for tokie to handle. Issue: https://github.com/near/nearcore/issues/3266 --- Cargo.lock | 5 +++-- neard/Cargo.toml | 1 + neard/src/cli.rs | 3 +++ runtime/near-vm-runner/Cargo.toml | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 314eab4e762..96d28ef353d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3765,6 +3765,7 @@ dependencies = [ "near-rust-allocator-proxy", "nearcore", "openssl-probe", + "tokio", "tracing", "tracing-subscriber", ] @@ -6422,9 +6423,9 @@ dependencies = [ [[package]] name = "wasmer-runtime-core-near" -version = "0.17.3" +version = "0.17.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c65db7e27877fb7499a5af9d7ab763bb0ddc78c3d1a6310a8ca6e86e71e532f9" +checksum = "08ff9059d479dbff357e1953edbde198453d5421274119230c50754e61e8ec9f" dependencies = [ "bincode", "blake3", diff --git a/neard/Cargo.toml b/neard/Cargo.toml index b1692f7d1e7..a38eaa433c6 100644 --- a/neard/Cargo.toml +++ b/neard/Cargo.toml @@ -22,6 +22,7 @@ tracing-subscriber = "0.2.4" openssl-probe = "0.1.2" near-rust-allocator-proxy = { version = "0.2.8", optional = true } lazy_static = "1.4" +tokio = "1.1" nearcore = { path = "../nearcore" } near-primitives = { path = "../core/primitives" } diff --git a/neard/src/cli.rs b/neard/src/cli.rs index c8f0e70ca4b..82d9234c7c1 100644 --- a/neard/src/cli.rs +++ b/neard/src/cli.rs @@ -258,6 +258,9 @@ impl RunCmd { let sys = actix::System::new(); sys.block_on(async move { nearcore::start_with_config(home_dir, near_config); + tokio::signal::ctrl_c().await.unwrap(); + info!("Got Ctrl+C, stopping"); + actix::System::current().stop(); }); sys.run().unwrap(); } diff --git a/runtime/near-vm-runner/Cargo.toml b/runtime/near-vm-runner/Cargo.toml index 2f64b58cd66..fe9b843375f 100644 --- a/runtime/near-vm-runner/Cargo.toml +++ b/runtime/near-vm-runner/Cargo.toml @@ -17,7 +17,7 @@ borsh = "0.8.1" serde = { version = "1", features = ["derive"] } wasmer-runtime = { version="0.17.1", features = ["default-backend-singlepass"], default-features = false, package = "wasmer-runtime-near", optional = true } # Always used even for wasmer 1.0 for validating wasm, will be replaced when refactor prepare.rs -wasmer-runtime-core = {version = "0.17.3", package = "wasmer-runtime-core-near" } +wasmer-runtime-core = {version = "0.17.4", package = "wasmer-runtime-core-near" } wasmer = { version = "1.0.2", optional = true } wasmer-types = { version = "1.0.2", optional = true } wasmer-compiler-singlepass = { version = "1.0.2", optional = true, default-features = false, features = ["std", "enable-serde"] } # disable `rayon` feature.