Skip to content

Settings: restart the daemon with POST /v1/restart and simlock daemon restart #1155

In review

Description

@leonardoxr

Part of #1151.

Scope

An admin restarts the daemon without a terminal on its machine: POST /v1/restart, daemon.restart, or simlock daemon restart. The daemon hands the restart to the updater process, which stops it and starts it again with no install. Leases are kept, as for any restart.

If this goes wrong, a daemon stops and does not come back, an update and a restart run at once, or a restart installs or rolls back a version.

Technical spec

Commit 096519b.

Rows

  • Behaviours: B12, B13, B14
  • Interfaces: I17, I18, I19
  • Existing code: X5, X15, X17, X18, X19, X20, X21, X22, X23, X24, X35, X38, X39

Facts

none

Modules touched

Searches: UpdaterLaunch, launcher.launch, parseUpdaterArgs, runUpdater, updateOptionsFor, stopRunningDaemon, REMOTE_REFUSED_PATHS, daemon stop in src and website.

  • src/contract/operations-admin.ts, src/contract/operations.ts, src/contract/protocol.ts, src/daemon/dispatcher.ts and its parts, src/daemon/server-requests.ts, src/gateway/dispatcher.ts.
  • src/daemon/update-coordinator.ts, src/daemon/settings.ts, src/daemon/worker-composition.ts, src/daemon/main.ts.
  • src/updater/index.ts, src/updater/main.ts, src/ports/updater-launcher.ts.
  • src/simlock-client/client-api.ts, src/simlock-client/client-impl.ts, src/simlock-client/client-degraded.ts, src/simlock-client/types.ts, src/admin/index.ts, website/src/content/docs/docs/reference/node-client.mdx: restartDaemon().
  • src/cli/commands/daemon.ts, src/cli/daemon-service.ts, src/cli/tree.ts, src/cli/index.ts, with Settings: change settings through the daemon with PATCH /v1/settings, live where it can #1154's wait limit reused.
  • src/http/admin-declarations.ts, src/http/app.ts.
  • src/updater/AGENTS.md, website/src/content/docs/docs/reference/cli.mdx, website/src/content/docs/docs/worker/daemon.mdx, website/src/content/docs/docs/worker/change-a-setting.mdx, website/src/content/docs/docs/getting-started/existing-farm.mdx.
flowchart LR
  CLI["cli daemon *"] --> D["dispatchers *"]
  H["http *"] --> D
  D --> U["update-coordinator *"]
  U --> L["ports updater-launcher *"]
  U --> S["daemon/settings *"]
  L -.spawns.-> P["updater *"]
Loading

Rules in play

  • ADR 0099 §6: stop, wait, start; refused while the file does not load; no update field, no update event.
  • ADR 0042: one detached updater; daemon.update's shape is frozen and does not change.
  • src/updater/AGENTS.md: main.ts imports everything statically, and both ends of the updater's lines change together.
  • src/contract/AGENTS.md, "Adding an operation": matrices, protocol, both dispatchers, client, HTTP, website.
  • Architecture rule 11: the CLI's wait is bounded.
  • Documentation rule 9: the CLI reference and the daemon page.

Tests

Seam: startDaemon with FakeUpdaterLauncher (model: src/daemon/main-update.test.ts), createHttpApp (model: src/http/app-updates.test.ts), runUpdater (model: src/updater/index.test.ts), the launcher (model: src/ports/updater-launcher.test.ts) and runCli (model: src/cli/index-daemon-service.test.ts).

  • B12: An admin restarts the daemon with POST /v1/restart and the daemon launches the updater once in restart mode: first call 202 and one launch with the pid and the role; a second call 202, no second launch; during an update, waiting included, 503 DAEMON_UPDATING; a new daemon.update during a restart DAEMON_STOPPING, while daemon.update {query} answers as today; config.json does not load: 400 and no launch; the launch throws: 500 INTERNAL and a later call launches again; the updater exits non-zero before the stop: a later call launches again, no daemon.update-failed, no update field set; an agent 403
  • B13: The updater in restart mode stops the daemon and starts it again, with no install: the launcher's arguments are --restart --pid <pid>, plus --gateway for a gateway; --restart with --from is refused; running at any version: exit 0, no npm call, no backup, no result file; the old pid still alive after 10 minutes: SIGKILL; not started in 2 minutes: one stderr line, exit 1, nothing reinstalled; a worker's start passes --local, in an update too
  • B14: simlock daemon restart asks the running daemon to restart: running: prints Daemon restarting, --json {"status":"restarting"}; none running: prints Daemon not running, --json {"status":"not-running"}, exit 0, as daemon stop does; a daemon that never answers: I19's error after 30 s, the connection closed; a refusal printed, exit by its code; --url: refused as daemon stop is; --gateway with no gateway: GATEWAY_NOT_PRESENT

Done when

  • daemon.restart is in the role and effect matrices of src/contract/operations.test.ts; daemon.update's pinned schemas there are unchanged.
  • A restart-mode run calls no npm.install and writes no update-backup and no update-result.json.
  • The website build and its HTTP API check pass, and the HTTP reference lists POST /v1/restart.

Out of scope

  • Restarting a worker through its gateway.
  • Waiting for leases to end, and an event of its own.

Depends on

Written by an agent.

Activity

  1. added
    task:draft
    on Nov 5, 2026
  2. added
    task:ready
    and removed
    task:draft
    on Nov 30, 2026
  3. self-assigned this
    on Dec 2, 2026
  4. 7 remaining items

  5. removed their assignment
    on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    task:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions