diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/Cargo.toml | 4 | ||||
-rw-r--r-- | server/makefile | 4 | ||||
-rw-r--r-- | server/src/main.rs | 15 |
3 files changed, 18 insertions, 5 deletions
diff --git a/server/Cargo.toml b/server/Cargo.toml index 498f85d..d8a08a5 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -16,3 +16,7 @@ serde_json = "1.0.99" include_dir = "0.7.3" toml = "0.7.5" grass = "0.12.4" + +[features] +default = [] +embed_config = [] diff --git a/server/makefile b/server/makefile index 6097a10..74876ae 100644 --- a/server/makefile +++ b/server/makefile @@ -4,8 +4,8 @@ release: target/release/keks-meet run: cargo +nightly run --release watch: - systemfd --no-pid -s http::8080 -- cargo watch -x '+nightly run' + systemfd --no-pid -s http::8080 -- cargo watch -x '+nightly run --features embed_config' watch-public: - systemfd --no-pid -s http::0.0.0.0:8080 -- cargo watch -x '+nightly run' + systemfd --no-pid -s http::0.0.0.0:8080 -- cargo watch -x '+nightly run --features embed_config' target/release/keks-meet: $(shell find src) Cargo.toml cargo +nightly build --release diff --git a/server/src/main.rs b/server/src/main.rs index d36681b..eb6e502 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -41,8 +41,16 @@ fn main() { async fn run() { env_logger::init_from_env("LOG"); - let config: Config = toml::from_str(include_str!("../../config/config.toml")) - .expect("client configuration invalid"); + #[cfg(feature = "embed_config")] + let config = include_str!("../../config/config.toml").to_string(); + #[cfg(not(feature = "embed_config"))] + let config = std::fs::read_to_string( + std::env::args() + .nth(1) + .expect("first argument should be the configuration"), + ) + .expect("cannot read configuration"); + let config: Config = toml::from_str(&config).expect("configuration invalid"); let client_config_json = serde_json::to_string(&config).unwrap(); let client_config_css = css_overrides(&config.appearance); @@ -55,7 +63,8 @@ async fn run() { .map(signaling_connect); let index: _ = warp::path!().and(s_file!("client-web/public/start.html", "text/html")); - let favicon: _ = warp::path!("favicon.ico").and(s_file!("client-web/public/favicon.ico", "image/avif")); + let favicon: _ = + warp::path!("favicon.ico").and(s_file!("client-web/public/favicon.ico", "image/avif")); let room: _ = warp::path!("room").and(s_file!("client-web/public/app.html", "text/html")); let assets: _ = warp::path("assets").and(s_asset_dir!()); let sw_script: _ = warp::path("sw.js").and(s_file!( |