Compare commits

..

No commits in common. "04ab968e0f7962f68fbcb03aeef6c4646205fa1f" and "e3fa95ab683ca5187b5ca4d0e3e2cbceba29bf07" have entirely different histories.

View File

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