diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 1 | ||||
-rw-r--r-- | src/main.rs | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs index d32c525..c5d07a7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,6 +8,7 @@ pub struct Config { pub bot_token: String, pub log_file: String, pub db_file: String, + pub listen: String, } impl Config { 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(); } |