Public: anyone can read this; the crew can change it.

A paused app's service port is released and says so on its page #16787

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A stopped service app now gives up its ports, and its page says so. A redeploy takes them back, or fails naming the app that holds one. This is issue #15111, now buildable because #14231 landed the running service kind.

Notes

opened this

A stopped service app now gives up its ports, and its page says so. A redeploy takes them back, or fails naming the app that holds one. This is issue #15111, now buildable because #14231 landed the running service kind.

The new tests, the existing service tests and three apps suites pass, and tsc and scripts/gate.ts are clean. I did not run the full suite: scripts/fast.ts named 3087 files (about 260 minutes), so I ran only those suites. The forge's check runs the rest on this push.

What counts as pause and a port. The repo has no "pause" for an app, so I took the owner's existing Stop (stopEnv) as pause and a redeploy as resume. There is no port allocator either; app.ports is only a declaration, and exposing the ports is still issue #391. So I defined holding: a running service's production environment holds its declared ports. Previews hold none, because every preview of a service would otherwise clash with its own production.

What changed

  • New src/apps/service_ports.ts. The ports a service holds are read from what is live, so there is no claims table to drift.
  • Stop on a service records what it gave up as parked, and the ports become free for other apps.
  • On a stopped or failed service, the environment's note reads "parked: port 25565 released for other apps; a redeploy takes it back, or says who holds it". The web app page and the terminal deploys screen both already show that field, so both doors get the words with no new component.
  • Before a production service starts, bringUp refuses if another app's production holds one of its ports. The error reads "port N is held by <slug>, which is running; stop it, or change app.ports in forge.json". The app stays parked.
  • A successful start clears the parked mark.
  • docs/APPS.md describes this in the service kind section.
  • test/service-ports.test.ts covers hold, free, park, a web app not being parked, and clash then resume.

What I did not do

  • Two deploys that start in the same instant can both pass the check, because it reads live state and nothing is claimed ahead of time.
  • The parked mark is in memory and is lost when the forge restarts.
  • The bringUp wiring is covered only by the clash function's tests, not by a full deploy test.
  • I added no dependency and did not touch src/http/server.ts.

To try it: run a service app, then Stop its production on the app page or in the deploys screen. The page shows the parked note. Deploy a second service that declares the same port and it starts. Redeploy the first and it fails naming the second app.

🤖 Generated with Claude Code

Closes #15111

3 earlier comments
commented

A stopped service app now gives up its ports, and its page says so. A redeploy takes them back, or fails naming the app that holds one. This is issue #15111, now buildable because #14231 landed the running service kind.

The new tests, the existing service tests and three apps suites pass, and tsc and scripts/gate.ts are clean. I did not run the full suite: scripts/fast.ts named 3087 files (about 260 minutes), so I ran only those suites. The forge's check runs the rest on this push.

What counts as pause and a port. The repo has no "pause" for an app, so I took the owner's existing Stop (stopEnv) as pause and a redeploy as resume. There is no port allocator either; app.ports is only a declaration, and exposing the ports is still issue #391. So I defined holding: a running service's production environment holds its declared ports. Previews hold none, because every preview of a service would otherwise clash with its own production.

What changed

  • New src/apps/service_ports.ts. The ports a service holds are read from what is live, so there is no claims table to drift.
  • Stop on a service records what it gave up as parked, and the ports become free for other apps.
  • On a stopped or failed service, the environment's note reads "parked: port 25565 released for other apps; a redeploy takes it back, or says who holds it". The web app page and the terminal deploys screen both already show that field, so both doors get the words with no new component.
  • Before a production service starts, bringUp refuses if another app's production holds one of its ports. The error reads "port N is held by <slug>, which is running; stop it, or change app.ports in forge.json". The app stays parked.
  • A successful start clears the parked mark.
  • docs/APPS.md describes this in the service kind section.
  • test/service-ports.test.ts covers hold, free, park, a web app not being parked, and clash then resume.

What I did not do

  • Two deploys that start in the same instant can both pass the check, because it reads live state and nothing is claimed ahead of time.
  • The parked mark is in memory and is lost when the forge restarts.
  • The bringUp wiring is covered only by the clash function's tests, not by a full deploy test.
  • I added no dependency and did not touch src/http/server.ts.

To try it: run a service app, then Stop its production on the app page or in the deploys screen. The page shows the parked note. Deploy a second service that declares the same port and it starts. Redeploy the first and it fails naming the second app.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. tsc --noEmit is clean and the two port test files pass, but I did not run the full suite.

The only conflict was test/service-ports.test.ts, which both sides had created. I kept main's tests there, which cover manifest port parsing and the portClash and deployPortRefusal checks in service.ts. The parked-service tests from this branch are now in test/service-parked.test.ts. They cover heldPorts, portClash and parkedWords from service_ports.ts, and a stopped service releasing its ports. bun scripts/gate.ts --fix changed nothing.

The auto-merged docs/APPS.md and src/apps/runtime_bringup.ts merged without conflicts, and I did not review the combined result. service.ts and service_ports.ts now each define their own portClash, with different signatures. I did not unify them.

commented

Review round addressed; pushed. tsc --noEmit is clean and the port, parked and TUI note tests pass. I didn't run the whole suite, so the forge's check will be the first full run.

What is new in this pull, now that main already had the port check: a stopped service production is marked parked, and its page and the terminal's Deploys screen say so. The words are "parked: port 25565 released for other apps; a redeploy takes it back, or says who holds it". The mark clears when a deploy lands or the environment is removed.

  1. One check. I deleted the second portClash in service_ports.ts and its call in bringUp. deployPortRefusal in service.ts is now the only clash check, with its wording: forge.json: port 25565 is already held by mc; hello cannot declare it. service_ports.ts keeps only heldPorts, parkedWords and the Parked type.
  2. Resume test. test/service-parked.test.ts now drives the real deploy path:
    • It stops a service, so it is parked, and puts another app's production on the port.
    • It calls requestDeploy. The run fails, lastError is the refusal naming mc, and parked stays set.
    • It removes the holder and deploys again. The deploy lands and parked and lastError clear.
    • A bringUp regression such as deleting the deployPortRefusal call would fail it.
    • It fakes the service declaration by overriding heldFor, so it does not exercise a real service process.
  3. Terminal and how-to. test/tui-deploys-service-note.test.ts already proves the screen shows production's note. I added a case there with the real parked words. The how-to is docs/features/service-parked.md, and the APPS.md paragraph now points to it. The gate's door rules pass.
  4. Teardown. teardown now clears parked, and a test covers it.

I disagree with nothing. The hold note about the trevato/forge release didn't touch this change.

commented

The failing gate rule is fixed and pushed. Locally the gate and bun x tsc --noEmit pass and test/service-parked.test.ts passes (3 tests). I haven't seen the forge's check re-run yet.

The only change is in test/service-parked.test.ts. The heldPorts test now builds a typed ServiceSpec and a real live record instead of casting with as never. The test itself and the rest of the pull are unchanged: a stopped service's ports are released and the app is shown as parked, a redeploy onto a port another app holds is refused and stays parked, and a deploy that lands (or tearing the environment down) clears the mark.

To try it, run bun test test/service-parked.test.ts.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs