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

A long-running services kind: declared ports, always on, placed on the owner's hardware, for a Minecraft network and its websites #1367

Closed opened this in answer to
Closed without merging

This lands the service kind for TCP only. UDP, volume sync and the companion-website link are not built, so the issue is not done. I haven't run a service through the deploy path, and the publish test can't run in this sandbox.

Notes

stopped closed without shipping

opened this

This lands the service kind for TCP only. UDP, volume sync and the companion-website link are not built, so the issue is not done. I haven't run a service through the deploy path, and the publish test can't run in this sandbox.

What changed

  • Ports (src/apps/service.ts): ports takes 25565, "19132/udp" or {port, protocol}. A port may be declared as both tcp and udp.
  • Placement (src/apps/service.ts, new src/apps/placement.ts): placement is now any node label, not just metal/cloud. A node carries the labels in FORGE_NODE_LABELS. A service that wants a label the node lacks fails its deploy with that reason in the log. This checks placement on the node the deploy runs on; it does not choose a node.
  • Health (src/apps/service.ts, src/apps/process.ts): a new health_command runs in its own cell. That cell reaches the published ports on 127.0.0.1, and FORGE_SERVICE_PORTS lists them. The deploy is ready when the command exits 0. With no command, or in a preview, ready means the process stayed up for 1.5 s.
  • Published ports (src/apps/contain.ts, src/apps/egress.ts): CellSpec.publish relays TCP ports on all host addresses, byte for byte, never proxied. A service gets no listen relay for the forge's HTTP proxy. Only the production environment publishes. Previews run without ports, because production holds them.
  • Always on (src/apps/runtime.ts): the sweep skips services, so they never sleep.
  • Docs (docs/APPS.md): the service section is rewritten.
  • Tests (test/apps-adversarial.test.ts, test/contain-publish.test.ts): the manifest and placement tests pass here. The echo-through-the-cell test returns early here because this sandbox can't listen on unix sockets. test/contain.test.ts has the same 10 failures with and without my change. tsc --noEmit is clean.

Not done

  • UDP relay: udp ports validate, but the deploy refuses with that reason. A Minecraft Java server works; Bedrock and voice-chat plugins need the datagram relay.
  • Volume sync: still issue #391.
  • Companion site reaching a service: cells refuse private addresses, so the site can't reach a service yet. It needs a declared uses field and a lookup from service name to ports. I didn't build the example site either.
  • Community pulls and the vxrail rehearsal: I did nothing here. The existing outsider gate is untouched, and the rehearsal needs the hardware.

Try it: deploy a repository whose forge.json has kind: "service", ports: [25565] and run set to a TCP server, on a node started with FORGE_NODE_LABELS including its placement. Then nc <host> 25565.

🤖 Generated with Claude Code

Closes #1118

1 earlier comment · 2 events
Changes requested — before the latest push

Reviewed from the diff, the preview and the screenshots; I did not run the tests. The service kind parses, publishes TCP ports and checks a placement label. Four things are missing for it to land.

  1. Security: a manifest can claim any host port. publish binds 0.0.0.0:<port> for any value from 1024 to 65535. Nothing checks that port against the forge's own listeners, the SSH/tty port, another app's service, or a port the host already uses. Anyone who can push a production forge.json can take or collide with those ports. Add a boundary check: refuse a port that is reserved or already published by another app, and fail the deploy with a plain sentence. Test that refusal.
  2. Tests do not cover the new behaviour.
    • contain-publish.test.ts returns silently when bubblewrap or unix sockets are unavailable, so it can pass without testing anything. Use test.skipIf or make it assert.
    • Nothing tests the udp refusal in startProcess, the placement refusal at deploy, waitUntilServiceReady, or the new live.manifest.service !== null exclusion in the runtime sweep. Removing any of these would leave bun test green.
  3. Both doors and the preview. A service has no surface on the page or in src/tty.ts: no status, ports or placement. The README is untouched; only docs/APPS.md changed. The preview cannot show it working, and the issue says done means reachable on the page, in MCP, in a test and by eye. At minimum show a service's ports, state and placement in the app view and in the tty, and say how to use it in the README.
  4. Late failure for udp. parseService accepts udp ports, then every deploy fails. Either reject udp in the parser with that sentence or keep the parse but surface it when the manifest is read, not at deploy.

Smaller points:

  • The health command runs with a 10 s per-attempt timeout, so the ready budget can be overshot by up to 10 s.
  • The indentation inside openCell({...}) in the new test file is off.
the crew's run was interrupted: restart, resumes on the next pass — cancelled
commented

This is the service kind for TCP only, and the issue is still not done. I haven't run a service through the deploy path.

Changes since the last push

  • Port conflicts (juniper's first comment):
    • A production deploy now fails, before the checkout, with a plain sentence when a port is already taken.
    • The refused ports are:
      • the forge's own listener (PORT);
      • the terminal (FORGE_SSH_PORT; none when it is 0);
      • anything in FORGE_RESERVED_PORTS;
      • common host daemons (3306, 5432, 6379, 8080, 8443, 9090, 9100, 10250, 27017);
      • 32768 and up, where the forge hands ports to apps;
      • any port another app's production service already publishes, named by that app's slug.
    • This lives in src/apps/ports.ts and is called from src/apps/runtime.ts.
    • Tests for each refusal are in test/service-kind.test.ts.
  • Visible skips and unit tests (juniper's second comment):
    • The publish test in test/contain-publish.test.ts now uses test.skipIf. It skips visibly when there is no bubblewrap or the sandbox can't listen on unix sockets.
    • New tests in test/service-kind.test.ts need no cell: the placement refusal, the sweep exclusion (mayIdle), the health-command ready logic, and the service line shown on the app page and in ssh.
  • UDP is now refused at parse: a 19132/udp port fails the manifest with "the forge cannot relay udp yet". It no longer parses and then fails later at deploy. This changes what I described before, so please check it is what you want.
  • Health budget: the last health attempt is cut at the ready budget instead of running its own 10 s past it.
  • Status: the app page and ssh into a service show its placement, its ports, and whether they are published. The README and docs/APPS.md are updated.

Tests

  • tsc --noEmit is clean.
  • test/service-kind.test.ts passes, 15 tests.
  • test/apps-adversarial.test.ts has the same 9 failures with and without my change, all from this sandbox refusing unix sockets.
  • The cell echo test skipped here. It has never run in this sandbox, so published ports have not been exercised end to end.

Still not done

  • A UDP relay, so Bedrock and voice-chat plugins don't work yet.
  • Volume sync (issue #391).
  • A companion site reaching a service by name.
  • Choosing a node, as opposed to checking the label on the node the deploy runs on.
  • The vxrail rehearsal.

Try it: deploy a repository with kind: "service" and ports: [25565]. Run its run command as a TCP server on a node started with FORGE_NODE_LABELS including its placement, then nc <host> 25565.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs