Webapp
This commit is contained in:
+46
-2
@@ -1,3 +1,47 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
mod api;
|
||||
mod data_value;
|
||||
mod dto;
|
||||
mod engine;
|
||||
mod index_key;
|
||||
mod ingest;
|
||||
mod metric_primitive;
|
||||
mod timestamp;
|
||||
|
||||
use clap::Parser;
|
||||
use tokio::net::TcpListener;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
/// Observability dashboard from terminal output.
|
||||
#[derive(Parser, Debug)]
|
||||
struct Args {
|
||||
/// Port to serve the API and webapp on.
|
||||
#[arg(long, default_value_t = 8420)]
|
||||
port: u16,
|
||||
|
||||
/// Directory containing the built webapp (index.html + assets).
|
||||
#[arg(long, default_value = "webapp/dist")]
|
||||
static_dir: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let (engine_tx, engine_rx) = mpsc::channel(1024);
|
||||
tokio::spawn(engine::run(engine_rx));
|
||||
tokio::spawn(ingest::run(engine_tx.clone()));
|
||||
|
||||
let app = api::router(engine_tx, &args.static_dir);
|
||||
let listener = TcpListener::bind(("0.0.0.0", args.port))
|
||||
.await
|
||||
.expect("failed to bind listener");
|
||||
|
||||
eprintln!(
|
||||
"ottyl serving on http://localhost:{} (reading logs from stdin)",
|
||||
args.port
|
||||
);
|
||||
|
||||
axum::serve(listener, app)
|
||||
.await
|
||||
.expect("server error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user