34 lines
981 B
TypeScript
34 lines
981 B
TypeScript
import { spawn } from "bun"
|
|
|
|
console.log("\n\n----------------------------------")
|
|
console.log(`Node Environment: ${process.env.NODE_ENV || "development"}`)
|
|
console.log(`Bun Version: ${Bun.version}`)
|
|
console.log("----------------------------------\n\n")
|
|
|
|
const run = async (cmd: string[]) => {
|
|
const commandText = cmd.join(" ")
|
|
const proc = spawn(cmd, {
|
|
stdout: "inherit",
|
|
stderr: "inherit",
|
|
})
|
|
|
|
const status = await proc.exited
|
|
|
|
if (status !== 0) {
|
|
throw new Error(`Process "${commandText}" failed with exit code ${status}`)
|
|
} else {
|
|
console.log(`👋 Process ${commandText}(PID ${proc.pid}) exited with code ${status}`)
|
|
}
|
|
|
|
return status
|
|
}
|
|
|
|
try {
|
|
await Promise.all([run(["bun", "run", "--filter=@workshop/http", "start"]), run(["bun", "bot:discord"])])
|
|
console.log("✅ All processes completed successfully")
|
|
} catch (error) {
|
|
console.log(`🌭`, error.message)
|
|
console.error("❌ One or more processes failed:", error)
|
|
process.exit(1)
|
|
}
|