Compare commits

...

2 Commits

Author SHA1 Message Date
Chris Wanstrath
04ab968e0f fix ports 2025-10-10 16:19:24 -07:00
Chris Wanstrath
7477086322 inherit env 2025-10-10 16:16:37 -07:00

View File

@ -16,7 +16,8 @@ export type App = Hono | Handler
const processes = new Map<string, { port: string, proc: ReturnType<typeof Bun.spawn> }>()
const restarting = new Set<string>()
let nextPort = 4000
const STARTING_PORT = 10000
let nextPort = STARTING_PORT
export async function initWebapps() {
await startSubprocs()
@ -57,9 +58,11 @@ async function startApp(name: string): Promise<string | undefined> {
if (existing) return existing.port
const port = String(nextPort++)
if (nextPort >= STARTING_PORT * 2) nextPort = STARTING_PORT
const proc = Bun.spawn({
cmd: [BUN_BIN, "run", "src/webapp/worker.ts", name],
env: { PORT: port },
env: { ...process.env, PORT: String(port) },
stdout: "inherit",
stderr: "inherit",
})
@ -84,7 +87,7 @@ function serveStatic(path: string): Response {
export async function shutdownWebapps() {
wwwWatcher?.close()
nextPort = 4000
nextPort = STARTING_PORT
for (const [name, { port, proc }] of processes) {
webappLog(name, "Shutting down")