@@ -20,7 +20,7 @@ use std::{mem, sync::Arc};
2020
2121use tokio:: sync:: mpsc;
2222use tower:: { Service , ServiceExt } ;
23- use tracing:: level_filters:: LevelFilter ;
23+ use tracing:: { info , level_filters:: LevelFilter } ;
2424use tracing_subscriber:: { layer:: SubscriberExt , reload:: Handle , util:: SubscriberInitExt , Registry } ;
2525
2626use cuprate_consensus_context:: {
@@ -141,13 +141,19 @@ fn main() {
141141 . await ;
142142
143143 // Start the command listener.
144- let ( command_tx, command_rx) = mpsc:: channel ( 1 ) ;
145- std:: thread:: spawn ( || commands:: command_listener ( command_tx) ) ;
144+ if std:: io:: IsTerminal :: is_terminal ( & std:: io:: stdin ( ) ) {
145+ let ( command_tx, command_rx) = mpsc:: channel ( 1 ) ;
146+ std:: thread:: spawn ( || commands:: command_listener ( command_tx) ) ;
146147
147- // Wait on the io_loop, spawned on a separate task as this improves performance.
148- tokio:: spawn ( commands:: io_loop ( command_rx, context_svc) )
149- . await
150- . unwrap ( ) ;
148+ // Wait on the io_loop, spawned on a separate task as this improves performance.
149+ tokio:: spawn ( commands:: io_loop ( command_rx, context_svc) )
150+ . await
151+ . unwrap ( ) ;
152+ } else {
153+ // If no STDIN, await OS exit signal.
154+ info ! ( "Terminal/TTY not detected, disabling STDIN commands" ) ;
155+ tokio:: signal:: ctrl_c ( ) . await . unwrap ( ) ;
156+ }
151157 } ) ;
152158}
153159
0 commit comments