From 1aef482972cdb0a1d7c0b7571b3a1f64390dc918 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 21 Jun 2020 19:31:25 +0000 Subject: [PATCH] ledger-tool: Ignore SIGUSR1 (#10730) (#10731) Prevents warehouse archive calls getting KO'd by logrotate (cherry picked from commit d42247c6524f249247ab39eb28cfe0da3069362e) Co-authored-by: Trent Nelson --- Cargo.lock | 1 + ledger-tool/Cargo.toml | 3 +++ ledger-tool/src/main.rs | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index ed83a94377..8c4b14c906 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3581,6 +3581,7 @@ dependencies = [ "log 0.4.8", "serde_json", "serde_yaml", + "signal-hook", "solana-clap-utils", "solana-cli", "solana-ledger", diff --git a/ledger-tool/Cargo.toml b/ledger-tool/Cargo.toml index a50ad13554..f6a88a847f 100644 --- a/ledger-tool/Cargo.toml +++ b/ledger-tool/Cargo.toml @@ -29,5 +29,8 @@ tempfile = "3.1.0" [dev-dependencies] assert_cmd = "1.0" +[target."cfg(unix)".dependencies] +signal-hook = "0.1.15" + [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index b5db5592eb..ef19280dd7 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -585,6 +585,16 @@ fn open_genesis_config_by(ledger_path: &Path, matches: &ArgMatches<'_>) -> Genes #[allow(clippy::cognitive_complexity)] fn main() { + // Ignore SIGUSR1 to prevent long-running calls being killed by logrotate + // in warehouse deployments + #[cfg(unix)] + { + // `register()` is unsafe because the action is called in a signal handler + // with the usual caveats. So long as this action body stays empty, we'll + // be fine + unsafe { signal_hook::register(signal_hook::SIGUSR1, || {}) }.unwrap(); + } + const DEFAULT_ROOT_COUNT: &str = "1"; solana_logger::setup_with_default("solana=info");