Skip to content

Commit 6327ee6

Browse files
committed
Add break-glass mode
1 parent dbbf14c commit 6327ee6

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/main.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async fn main() -> anyhow::Result<()> {
7878

7979
// Create the external shutdown signal (used to shut down Ground
8080
// Control on UNIX signals).
81-
let (shutdown_sender, shutdown_receiver) = mpsc::unbounded_channel();
81+
let (shutdown_sender, mut shutdown_receiver) = mpsc::unbounded_channel();
8282

8383
let sigint_shutdown_sender = shutdown_sender.clone();
8484
tokio::spawn(async move {
@@ -98,6 +98,25 @@ async fn main() -> anyhow::Result<()> {
9898
let _ = sigterm_shutdown_sender.send(());
9999
});
100100

101-
// Run the Ground Control specification.
102-
groundcontrol::run(config, shutdown_receiver).await
101+
// Run the Ground Control specification, *unless* we are in
102+
// break-glass mode, in which case we freeze startup and just wait
103+
// for the shutdown signal. (this gives the admin a chance to SSH
104+
// into a machine that is in a startup-crash loop, perhaps due to an
105+
// issue on an attached, persistent storage volume)
106+
if std::env::var_os("BREAK_GLASS").is_none() {
107+
groundcontrol::run(config, shutdown_receiver).await
108+
} else {
109+
tracing::info!("BREAK GLASS MODE: no processes will be started");
110+
111+
shutdown_receiver
112+
.recv()
113+
.await
114+
.expect("All shutdown senders closed without sending a shutdown signal.");
115+
116+
tracing::info!(
117+
"Shutdown signal triggered (make sure to clear the `BREAK_GLASS` environment variable)"
118+
);
119+
120+
Ok(())
121+
}
103122
}

0 commit comments

Comments
 (0)