summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-08-03 13:05:31 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-08-08 12:08:20 +0200
commitf700fed45a9eeeede4a592568068ab52d719512f (patch)
tree3aff3af5002f9a16bfba3e5f248d67e02faecdc2
parent59def7d978787f67d741981a22b101dd5fa129d8 (diff)
Add ctrl-c handler for killing application
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs4
2 files changed, 5 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index e0b546a..e5e9397 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,3 +26,4 @@ serde = { version = "1", features = ["derive"] }
syntect = "4.5"
tokio = { version = "1", features = ["rt-multi-thread", "fs", "sync", "macros"] }
typed-builder = "0.9"
+ctrlc = "3.1"
diff --git a/src/main.rs b/src/main.rs
index 8f501da..7b55131 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -27,6 +27,10 @@ async fn main() {
async fn app() -> Result<()> {
env_logger::init();
+ ctrlc::set_handler(|| {
+ std::process::exit(1);
+ })?;
+
let cli = crate::cli::cli().get_matches();
let bind = cli.value_of("bind").unwrap(); // safe by clap
let port = cli.value_of("port").unwrap(); // safe by clap