Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ authors = ["Jason McCampbell <[email protected]>"]
edition = "2018"

[dependencies]
async-ctrlc = "^1.2"
bincode = "1"
byteorder = "1"
bytes = "^1"
Expand Down
8 changes: 8 additions & 0 deletions src/server.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extern crate async_ctrlc;
extern crate get_if_addrs;
extern crate priority_queue;
extern crate rand;
Expand Down Expand Up @@ -459,6 +460,9 @@ pub async fn run(max_cpus: Option<usize>, alt_start_cmd: bool, both_queues: bool
let watchdog = tokio::time::sleep(Duration::from_secs(5));
tokio::pin!(watchdog);

// Future waiting for ctrl-C signal. Can this realistically fail and need better error handling?
let mut ctrlc = async_ctrlc::CtrlC::new().expect("Error installing ctrl-C handler, aborting");

// Server state includes the user configuration from .spraycc, plus overrides
let mut server_state = ServerState::new(callme, user_key, max_cpus, alt_start_cmd, both_queues, verbose);
let user_private_key = server_state.user_private_key;
Expand Down Expand Up @@ -495,6 +499,10 @@ pub async fn run(max_cpus: Option<usize>, alt_start_cmd: bool, both_queues: bool
server_state.bytes_this_period = ByteUnit::Byte(0);
watchdog.as_mut().reset(Instant::now() + Duration::from_secs(5));
}
_ = &mut ctrlc => {
println!("SprayCC: ctrl-C received, shutting down");
break;
}
}

if server_state.ok_to_shutdown() {
Expand Down