Skip to content

Commit 2b76280

Browse files
Upgrade main.rs according to the changes
1 parent 3ae4d5c commit 2b76280

File tree

3 files changed

+39
-4
lines changed

3 files changed

+39
-4
lines changed

Cargo.lock

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rumqttd/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tokio = { version = "1.36", features = ["rt", "time", "net", "io-util", "macros"
1616
serde = { version = "1.0.196", features = ["derive"] }
1717
serde_json = "1.0.113"
1818
bytes = { version = "1", features = ["serde"] }
19+
ctrlc = "3.4"
1920
flume = { version = "0.11.0", default-features = false, features = ["async"]}
2021
slab = "0.4.9"
2122
thiserror = "1.0.57"

rumqttd/src/main.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,15 @@ fn main() {
8484

8585
validate_config(&configs);
8686

87-
// println!("{:#?}", configs);
87+
let _guard = Broker::new(configs).start().unwrap().drop_guard();
8888

89-
let mut broker = Broker::new(configs);
90-
broker.start().unwrap();
89+
let (tx, rx) = flume::bounded::<()>(1);
90+
ctrlc::set_handler(move || {
91+
let _ = tx.send(());
92+
})
93+
.expect("Error setting Ctrl-C handler");
94+
95+
rx.recv().expect("Could not receive Ctrl-C signal");
9196
}
9297

9398
// Do any extra validation that needs to be done before starting the broker here.

0 commit comments

Comments
 (0)