2021-03-22 12:46:10 +01:00
|
|
|
use hoc::{config::Settings, telemetry};
|
2019-06-12 21:51:54 +02:00
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
use std::net::TcpListener;
|
2019-04-19 16:01:47 +02:00
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
fn init() {
|
|
|
|
dotenv::dotenv().ok();
|
|
|
|
openssl_probe::init_ssl_cert_env_vars();
|
2019-04-16 16:57:06 +02:00
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
telemetry::init_subscriber(telemetry::get_subscriber("hoc", "info"))
|
2019-04-21 20:45:36 +02:00
|
|
|
}
|
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
#[actix_rt::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
init();
|
2020-11-01 13:57:56 +01:00
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
// TODO: error handling
|
|
|
|
let settings = Settings::load().expect("Cannot load config");
|
2019-04-30 15:22:58 +02:00
|
|
|
|
2021-03-22 12:46:10 +01:00
|
|
|
let address = format!("{}:{}", settings.host, settings.port);
|
|
|
|
// TODO: error handling
|
|
|
|
let listener = TcpListener::bind(address)?;
|
|
|
|
hoc::run(listener, settings)
|
|
|
|
.await
|
|
|
|
.expect("Server error")
|
2020-11-01 13:57:56 +01:00
|
|
|
.await
|
2019-07-07 14:52:42 +02:00
|
|
|
}
|