diff --git a/Justfile b/Justfile index 0efb6ee..97d5b34 100644 --- a/Justfile +++ b/Justfile @@ -1,5 +1,10 @@ +port := "8080" + serve wasm_profile="wasm-dev": (wasm wasm_profile) - cargo run -p rkgk + RKGK_PORT={{port}} cargo run -p rkgk wasm profile="wasm-dev": cargo build -p haku-wasm --target wasm32-unknown-unknown --profile {{profile}} + +deploy: + bash admin/deploy.bash diff --git a/admin/daemon.bash b/admin/daemon.bash index a5ceb59..3443db7 100755 --- a/admin/daemon.bash +++ b/admin/daemon.bash @@ -12,7 +12,7 @@ mkfifo $reload_fifo reload() { # This just kind of assumes recompilation doesn't take too long. kill "$rkgk_pid" - cargo run --release -- serve --port 8083 > "$build_log" 2>&1 & + just port=8083 serve wasm-release > "$build_log" 2>&1 & rkgk_pid="$!" } diff --git a/crates/rkgk/src/main.rs b/crates/rkgk/src/main.rs index 7962b85..d2686ac 100644 --- a/crates/rkgk/src/main.rs +++ b/crates/rkgk/src/main.rs @@ -1,5 +1,6 @@ use std::{ fs::{copy, create_dir_all, remove_dir_all}, + net::Ipv4Addr, path::Path, sync::Arc, }; @@ -102,10 +103,15 @@ async fn fallible_main() -> eyre::Result<()> { #[cfg(debug_assertions)] let app = app.nest("/dev/live-reload", live_reload::router()); - let listener = TcpListener::bind("0.0.0.0:8080") + let port: u16 = std::env::var("RKGK_PORT") + .unwrap_or("8080".into()) + .parse() + .context("failed to parse RKGK_PORT")?; + + let listener = TcpListener::bind((Ipv4Addr::from([0u8, 0, 0, 0]), port)) .await .expect("cannot bind to port"); - info!("listening on port 8080"); + info!("listening on port {port}"); axum::serve(listener, app).await.expect("cannot serve app"); Ok(())