geoffrey/src/main.rs

30 lines
683 B
Rust

#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
dotenv::dotenv().ok();
pretty_env_logger::init();
#[cfg(debug_assertions)]
{
info!("Activating DEBUG mode configuration");
}
if let Some(fd) = std::env::var("LISTEN_FD")
.ok()
.and_then(|fd| fd.parse().ok())
{
/*
* Allow the use of catflag for local development
* <https://github.com/passcod/catflap>
*/
use std::net::TcpListener;
use std::os::unix::io::FromRawFd;
app.listen(unsafe { TcpListener::from_raw_fd(fd) }).await?;
} else {
app.listen("0.0.0.0:8000").await?;
}
Ok(())
}