eust-w 56f124fab1
Some checks failed
CI / workbench (push) Has been cancelled
🚀 Release reproducible Real2Sim Studio alpha workbench
2026-10-28 01:13:52 +08:00

31 lines
1.0 KiB
JavaScript

import { spawn } from 'node:child_process'
import { fileURLToPath } from 'node:url'
const root = fileURLToPath(new URL('../', import.meta.url))
const demo = process.argv.includes('--demo')
const env = { ...process.env }
if (demo) {
env.REAL2SIM_DEMO = '1'
env.REAL2SIM_DATA_ROOT = `${root}.data/demo`
delete env.DASHSCOPE_API_KEY
delete env.REAL2SIM_ASSET_ROOT
delete env.REAL2SIM_GENESIS_PACKAGE_ROOT
}
const children = [
spawn(process.execPath, ['--import', 'tsx', 'server/index.ts'], { cwd: root, env, stdio: 'inherit' }),
spawn(process.execPath, ['node_modules/vite/bin/vite.js', '--host', '127.0.0.1'], { cwd: root, env, stdio: 'inherit' }),
]
let closing = false
function stop(code = 0) {
if (closing) return
closing = true
for (const child of children) child.kill('SIGTERM')
process.exitCode = code
}
for (const child of children) {
child.on('error', (error) => { console.error(error.message); stop(1) })
child.on('exit', (code) => stop(code || 0))
}
process.on('SIGINT', () => stop())
process.on('SIGTERM', () => stop())