diff options
| author | Jokler <jokler@protonmail.com> | 2020-10-17 19:55:58 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-17 19:55:58 +0000 |
| commit | 67c11897f164ff825a499f8c1296bb5c90658f06 (patch) | |
| tree | fc0198ee270a96350f64a8c42c42ff86beee6036 | |
| parent | 6dc5d6e808ad21208e69df1b46704ade76f027f7 (diff) | |
| parent | 48ccd0e7d7a63b7acc05ae9c9306869bf547a720 (diff) | |
| download | pokebot-master.tar.gz pokebot-master.zip | |
Added an option to the config file to disable the web server
| -rw-r--r-- | config.toml.example | 1 | ||||
| -rw-r--r-- | src/bot/master.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 15 |
3 files changed, 12 insertions, 6 deletions
diff --git a/config.toml.example b/config.toml.example index da39200..9f69d86 100644 --- a/config.toml.example +++ b/config.toml.example @@ -10,6 +10,7 @@ address = "localhost" channel = "Lobby" # Web server settings +webserver_enable = true domain = "localhost" bind_address = "127.0.0.1:45538" diff --git a/src/bot/master.rs b/src/bot/master.rs index 94332ac..2885dfe 100644 --- a/src/bot/master.rs +++ b/src/bot/master.rs @@ -36,6 +36,7 @@ pub struct MasterArgs { pub verbose: u8, pub domain: String, pub bind_address: String, + pub webserver_enable: bool, pub names: Vec<String>, pub id: Option<Identity>, pub ids: Option<Vec<Identity>>, @@ -345,6 +346,7 @@ impl MasterArgs { address, domain: self.domain, bind_address: self.bind_address, + webserver_enable: self.webserver_enable, id: self.id, channel, verbose, diff --git a/src/main.rs b/src/main.rs index 51b1e38..c7ad805 100644 --- a/src/main.rs +++ b/src/main.rs @@ -184,18 +184,21 @@ async fn run(root_logger: Logger) -> Result<(), Box<dyn std::error::Error>> { ctrl_c.await??; } else { + let webserver_enable = bot_args.webserver_enable; let domain = bot_args.domain.clone(); let bind_address = bot_args.bind_address.clone(); let bot_name = bot_args.master_name.clone(); let bot_logger = root_logger.new(o!("master" => bot_name.clone())); let bot = MasterBot::spawn(bot_args, bot_logger).await; - let web_args = web_server::WebServerArgs { - domain, - bind_address, - bot: bot.downgrade(), - }; - spawn_web_server(web_args, root_logger.new(o!("webserver" => bot_name))); + if webserver_enable { + let web_args = web_server::WebServerArgs { + domain, + bind_address, + bot: bot.downgrade(), + }; + spawn_web_server(web_args, root_logger.new(o!("webserver" => bot_name))); + } #[cfg(unix)] tokio::select! { |
