1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
extern crate openssl;
use anyhow::{format_err, Result};
use clap::{crate_version, load_yaml, App};
use log::info;
use std::env::set_var;
use webapp::config::Config;
use webapp_backend::Server;
fn main() -> Result<()> {
let yaml = load_yaml!("cli.yaml");
let matches = App::from_yaml(yaml).version(crate_version!()).get_matches();
let config_filename = matches
.value_of("config")
.ok_or_else(|| format_err!("No 'config' provided"))?;
let config = Config::from_file(config_filename)?;
set_var(
"RUST_LOG",
format!(
"actix_web={},webapp={},backend={}",
config.log.actix_web, config.log.webapp, config.log.webapp
),
);
env_logger::init();
info!(
"Starting server from config path {} for url {}",
config_filename, config.server.url
);
let server = Server::from_config(&config)?;
server.start()?;
Ok(())
}