From eaaa18f6eda7b05d88a8b4d32ff7756504ef2113 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 23 Oct 2023 17:30:25 +0100 Subject: [PATCH] attachment_service: graceful SIGQUIT (#5626) `attachment_service` doesn't explicitly handle signals, which causes a backtrace when `neon_local` kills it with SIGQUIT. Closes: https://github.com/neondatabase/neon/issues/5613 --- control_plane/src/bin/attachment_service.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/control_plane/src/bin/attachment_service.rs b/control_plane/src/bin/attachment_service.rs index d4bca59c7b..65ed78d20b 100644 --- a/control_plane/src/bin/attachment_service.rs +++ b/control_plane/src/bin/attachment_service.rs @@ -13,6 +13,7 @@ use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use std::{collections::HashMap, sync::Arc}; use utils::logging::{self, LogFormat}; +use utils::signals::{ShutdownSignals, Signal}; use utils::{ http::{ @@ -268,7 +269,16 @@ async fn main() -> anyhow::Result<()> { let server = hyper::Server::from_tcp(http_listener)?.serve(service); tracing::info!("Serving on {0}", args.listen); - server.await?; + + tokio::task::spawn(server); + + ShutdownSignals::handle(|signal| match signal { + Signal::Interrupt | Signal::Terminate | Signal::Quit => { + tracing::info!("Got {}. Terminating", signal.name()); + // We're just a test helper: no graceful shutdown. + std::process::exit(0); + } + })?; Ok(()) }