Skip to content

Commit 613644d

Browse files
authored
examples: cleanup unix socket file (#1137)
1 parent c29f293 commit 613644d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
5757
tracing-log = "0.2"
5858
serde_derive = "1.0"
5959
handlebars = "6.0"
60-
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
60+
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "signal"] }
6161
tokio-stream = "0.1.1"
6262

6363
[features]

examples/unix_socket.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ async fn main() {
77

88
pretty_env_logger::init();
99

10-
let listener = UnixListener::bind("/tmp/warp.sock").unwrap();
10+
let socket = "/tmp/warp.sock";
11+
12+
let listener = UnixListener::bind(socket).unwrap();
1113
warp::serve(warp::fs::dir("examples/dir"))
1214
.incoming(listener)
15+
.graceful(async { tokio::signal::ctrl_c().await.unwrap() })
1316
.run()
1417
.await;
18+
19+
std::fs::remove_file(socket).unwrap();
1520
}
1621

1722
#[cfg(not(unix))]

0 commit comments

Comments
 (0)