Something went wrong. Try again.
[ARCHIVED] A PLC Mirror written in Rust
Something went wrong. Try again.
1.1 kB · 39 lines
Rust
at main
12345678910111213141516171819202122232425262728293031323334353637383940use dropshot::{ConfigDropshot, ServerBuilder};use std::env::var;
const DEFAULT_BIND: &str = "127.0.0.1:8080";
#[tokio::main]async fn main() -> eyre::Result<()> { let log = plc_mirror::create_logger()?; let api = plc_mirror::create_api()?;
// make the log global and bridge to the log crate (for any other crates that use it) let _scope = slog_scope::set_global_logger(log.clone()); slog_stdlog::init()?;
let pool = plc_mirror::connect_db().await?;
let start_after = plc_mirror::get_start_after(&pool).await?;
tokio::spawn(plc_mirror::import::importer( log.clone(), pool.clone(), start_after, ));
let bind_address = var("PLC_BIND_ADDR") .unwrap_or(DEFAULT_BIND.to_string()) .parse()?;
let context = plc_mirror::ApiContext { pool };
let server = ServerBuilder::new(api, context, log) .config(ConfigDropshot { bind_address, ..Default::default() }) .start()?;
server.await.map_err(|e| eyre::Report::msg(e))}