23 lines
746 B
TypeScript
23 lines
746 B
TypeScript
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"])])
|