summaryrefslogtreecommitdiffstats
path: root/setup/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--setup/src/main.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/setup/src/main.rs b/setup/src/main.rs
new file mode 100644
index 0000000..90bd23d
--- /dev/null
+++ b/setup/src/main.rs
@@ -0,0 +1,55 @@
+use std::{
+ process::{Child, Command},
+ thread::sleep,
+ time::Duration,
+};
+
+struct Processes {
+ inner: Vec<Child>,
+}
+
+fn main() {
+ let mut processes = Processes { inner: vec![] };
+
+ processes.spawn_in_terminal(&[
+ "bash",
+ "-c",
+ "(cd ../rocie-server && eval \"$(direnv export bash 2>/dev/null)\" && bash -c 'cargo run --package rocie-server -- serve --port 8080')"
+ ]);
+ processes.spawn_in_terminal(&[
+ "bash",
+ "-c",
+ "trunk serve --proxy-backend=http://localhost:8080/ --proxy-rewrite=/api/",
+ ]);
+ processes.spawn_in_terminal(&[
+ "bash",
+ "-c",
+ "nix run n#floorp-bin -- http://localhost:3000",
+ ]);
+
+ loop {
+ sleep(Duration::from_secs(2 * 60 * 60));
+ }
+}
+
+impl Drop for Processes {
+ fn drop(&mut self) {
+ for process in &mut self.inner {
+ process.kill().unwrap();
+ }
+ }
+}
+
+impl Processes {
+ fn spawn_in_terminal(&mut self, args: &[&str]) {
+ let mut alacritty = Command::new("alacritty");
+ alacritty.arg("--hold");
+ alacritty.arg("--command");
+ alacritty.args(args);
+
+ eprintln!("Spawning `{:?}`", alacritty);
+
+ let new_child = alacritty.spawn().unwrap();
+ self.inner.push(new_child);
+ }
+}