2021-02-13 16:36:39 +01:00
|
|
|
use comunic_server::{cleanup_thread, server};
|
2020-05-20 19:05:59 +02:00
|
|
|
use comunic_server::data::config::{conf, Config};
|
2021-02-13 11:12:17 +01:00
|
|
|
use comunic_server::helpers::database;
|
2020-05-22 08:51:15 +02:00
|
|
|
|
2020-05-21 15:28:07 +02:00
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
2021-02-12 17:35:26 +01:00
|
|
|
let conf_file = match std::env::args().skip(1).next() {
|
|
|
|
Some(el) => el,
|
|
|
|
None => "config.yaml".to_string(),
|
|
|
|
};
|
2020-05-20 19:05:59 +02:00
|
|
|
|
|
|
|
// Load configuration
|
2021-02-12 17:35:26 +01:00
|
|
|
Config::load(&conf_file).expect("Could not load configuration!");
|
2020-05-20 19:05:59 +02:00
|
|
|
|
2020-05-21 09:21:58 +02:00
|
|
|
// Connect to the database
|
|
|
|
database::connect(&conf().database).expect("Could not connect to database!");
|
2020-05-20 19:05:59 +02:00
|
|
|
|
2021-02-13 16:36:39 +01:00
|
|
|
// Start cleanup thread
|
|
|
|
cleanup_thread::start().expect("Failed to start cleanup thread!");
|
|
|
|
|
2020-05-21 15:28:07 +02:00
|
|
|
// Start the server
|
|
|
|
server::start_server(conf()).await
|
2020-05-20 17:46:05 +02:00
|
|
|
}
|