aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorFelix Kaaman <tmtu@tmtu.ee>2020-02-22 23:27:01 +0100
committerGitHub <noreply@github.com>2020-02-22 23:27:01 +0100
commit763b8c6579f3ae571f7287c72b9fb4f8b6e89349 (patch)
treebc55a0e79107a93bc3e605a0cae32926dc4c52fc /src/main.rs
parent2792ba9c8a7120a91b3bd2c6075e737690e73405 (diff)
parent326cfa543c6263818aad7dec4a869bc8139ec14c (diff)
downloadpokebot-763b8c6579f3ae571f7287c72b9fb4f8b6e89349.tar.gz
pokebot-763b8c6579f3ae571f7287c72b9fb4f8b6e89349.zip
Merge pull request #33 from Mavulp/webserver
Webserver
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 922162f..2559a2a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,10 @@
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
+use std::thread;
use futures::future::{FutureExt, TryFutureExt};
-use log::{debug, info};
+use log::{debug, error, info};
use structopt::clap::AppSettings;
use structopt::StructOpt;
use tsclientlib::Identity;
@@ -13,6 +14,7 @@ mod bot;
mod command;
mod playlist;
mod teamspeak;
+mod web_server;
mod youtube_dl;
use bot::{MasterArgs, MasterBot, MusicBot, MusicBotArgs};
@@ -116,7 +118,22 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
};
MusicBot::new(bot_args).await.1.await;
} else {
- MasterBot::new(bot_args).await.1.await;
+ let domain = bot_args.domain.clone();
+ let bind_address = bot_args.bind_address.clone();
+ let (bot, fut) = MasterBot::new(bot_args).await;
+
+ thread::spawn(|| {
+ let web_args = web_server::WebServerArgs {
+ domain,
+ bind_address,
+ bot,
+ };
+ if let Err(e) = web_server::start(web_args) {
+ error!("Error in web server: {}", e);
+ }
+ });
+
+ fut.await;
}
}
.unit_error()