Skip to content

Commit

Permalink
wip: sketch spawning processes
Browse files Browse the repository at this point in the history
  • Loading branch information
cablehead committed Jun 6, 2024
1 parent fba7ae5 commit 1011abf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,27 @@ struct Args {
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
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
}

0 comments on commit 1011abf

Please sign in to comment.