2021-07-19 18:35:52 -04:00
|
|
|
use actix_web::middleware::Logger;
|
2021-07-23 15:52:00 -04:00
|
|
|
use actix_web::{App, HttpServer};
|
|
|
|
use oops::config::Config;
|
|
|
|
use oops::server;
|
|
|
|
use std::fs;
|
|
|
|
use std::io::Result as IoResult;
|
2021-07-19 18:35:52 -04:00
|
|
|
|
|
|
|
#[actix_web::main]
|
2021-07-23 15:52:00 -04:00
|
|
|
async fn main() -> IoResult<()> {
|
2021-07-19 18:35:52 -04:00
|
|
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
2021-07-23 15:52:00 -04:00
|
|
|
let config = Config::parse("config").expect("failed to parse config");
|
|
|
|
let server_config = config.server.clone();
|
|
|
|
fs::create_dir_all(server_config.upload_path)?;
|
|
|
|
let mut http_server = HttpServer::new(move || {
|
|
|
|
App::new()
|
|
|
|
.data(config.clone())
|
|
|
|
.wrap(Logger::default())
|
|
|
|
.configure(server::configure_routes)
|
|
|
|
})
|
|
|
|
.bind(server_config.address)?;
|
|
|
|
if let Some(workers) = server_config.workers {
|
|
|
|
http_server = http_server.workers(workers);
|
|
|
|
}
|
|
|
|
http_server.run().await
|
2021-07-19 15:16:13 -04:00
|
|
|
}
|