summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-03-27 20:17:23 +0800
committerKeuin <[email protected]>2022-03-28 00:11:45 +0800
commitc4d5507e9c0b16b0d34df9e871be1d76d296ecea (patch)
treef4d6b7c3acdeff813ffbee104977bcff55227f15 /src/main.rs
parent3a5bafbc1e5fde298aacaf6f50edb8731983cd07 (diff)
Configurable HTTP listen endpoint.
Handle Ctrl-C correctly.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index fffdb65..65e01b2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
use std::convert::Infallible;
+use std::net::SocketAddr;
use std::sync::Arc;
use log::{debug, error, info, warn};
@@ -51,5 +52,12 @@ async fn main() {
tokio::spawn(bot::repl(bot, Arc::new(db)));
- warp::serve(send_message).run(([127, 0, 0, 1], 3030)).await;
+ let endpoint: SocketAddr = config.listen.parse()
+ .expect("Cannot parse `listen` as endpoint.");
+
+ println!("Listen on {}", endpoint);
+
+ tokio::spawn(warp::serve(send_message).run(endpoint));
+
+ tokio::signal::ctrl_c().await.unwrap();
}