From 1011abf2ea2e229fb912171a0f3f2386bffad412 Mon Sep 17 00:00:00 2001 From: Andy Gayton Date: Wed, 5 Jun 2024 22:29:19 -0400 Subject: [PATCH] wip: sketch spawning processes --- src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.rs b/src/main.rs index 97d0c00..c80ffb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,12 +19,27 @@ struct Args { async fn main() -> Result<(), Box> { let args = Args::parse(); let store = Store::spawn(args.path); + if let Some(addr) = args.http { let store = store.clone(); tokio::spawn(async move { let _ = xs::http::serve(store, &addr).await; }); } + + tokio::spawn(async move { + let origin = "wss://gateway.discord.gg"; + let command = format!( + "websocat {} --ping-interval 5 --ping-timeout 10 -E -t", + origin + ); + let _ = tokio::process::Command::new("sh") + .arg("-c") + .arg(command) + .spawn() + .expect("Failed to spawn command"); + }); + xs::api::serve(store).await // TODO: graceful shutdown }