diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..f6d8252 --- /dev/null +++ b/main.ts @@ -0,0 +1,22 @@ +import { spawn } from "bun" + +console.log(`Node Environment: ${process.env.NODE_ENV || "development"}`) +console.log(`Bun Version: ${Bun.version}`) + +const run = async (cmd: string[]) => { + const commandText = cmd.join(" ") + console.log(`🆕 Starting process: ${commandText}`) + const proc = spawn(cmd, { stdout: "inherit", stderr: "inherit" }) + console.log(`ðŸŠī Spawned PID ${proc.pid} for ${commandText}`) + + try { + const status = await proc.exited + console.log(`👋 Process ${commandText} (PID ${proc.pid}) exited with code ${status}`) + return status + } catch (err) { + console.error(`ðŸ’Ĩ Error waiting for ${commandText} exit:`, err) + throw err + } +} + +await Promise.all([run(["bun", "bot:discord"]), run(["bun", "http"])]) diff --git a/package.json b/package.json index 6658909..73d167f 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "scripts": { "http": "bun run --filter=@the-rabbit-hole/http start", "bot:cli": "bun run --filter=@the-rabbit-hole/spike bot:cli", - "bot:discord": "bun run --filter=@the-rabbit-hole/spike bot:discord" + "bot:discord": "bun run --filter=@the-rabbit-hole/spike bot:discord", + "start": "bun run main.ts" } } \ No newline at end of file