pub(crate) fn new_state(conf: Configuration) -> Arc<AppState>
Examples found in repository?
web/src/main.rs (line 172)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
async fn main() {
let config_path = std::env::args()
.nth(1)
.expect("Expected configuration file path as first argument.");
if ["-v", "--version", "info"].contains(&config_path.as_str()) {
println!("{}", crate::get_git_sha());
println!("{CLI_INFO}");
return;
}
#[cfg(test)]
let verbosity = log::LevelFilter::Trace;
#[cfg(not(test))]
let verbosity = log::LevelFilter::Info;
stderrlog::new()
.quiet(false)
.verbosity(verbosity)
.show_module_names(true)
.timestamp(stderrlog::Timestamp::Millisecond)
.init()
.unwrap();
let conf = Configuration::from_file(config_path).unwrap();
let app = create_app(new_state(conf));
let hostname = std::env::var("HOSTNAME").unwrap_or_else(|_| "0.0.0.0".to_string());
let port = std::env::var("PORT").unwrap_or_else(|_| "3000".to_string());
let listen_to = format!("{hostname}:{port}");
println!("Listening to {listen_to}...");
axum::Server::bind(&listen_to.parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}