46 lines
980 B
Rust
46 lines
980 B
Rust
/**
|
|
* This module contains the main entrypoint for Geoffrey
|
|
*/
|
|
#[macro_use]
|
|
extern crate serde_json;
|
|
|
|
use log::*;
|
|
|
|
mod dao;
|
|
mod routes;
|
|
mod state;
|
|
|
|
#[async_std::main]
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
use crate::state::AppState;
|
|
|
|
dotenv::dotenv().ok();
|
|
pretty_env_logger::init();
|
|
|
|
#[cfg(debug_assertions)]
|
|
{
|
|
info!("Activating DEBUG mode configuration");
|
|
}
|
|
|
|
let state = AppState::new();
|
|
let mut app = tide::with_state(state);
|
|
routes::views::register(&mut app);
|
|
|
|
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(())
|
|
}
|