c8ctl-plugin-nano 1.20.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +66 -0
  2. package/c8ctl-plugin.js +1238 -6
  3. package/package.json +8 -8
package/README.md CHANGED
@@ -205,8 +205,16 @@ c8ctl nano work reviewer --job-type senior:pr-review --job-type senior:triage
205
205
  ```bash
206
206
  c8ctl nano work reviewer # poll for work until Ctrl-C
207
207
  c8ctl nano work reviewer --max-parallel 2 --job-timeout 600000
208
+ c8ctl nano work reviewer --name reviewer-eu # name this worker (else auto ‹host›-‹profile›-‹random›)
208
209
  ```
209
210
 
211
+ The optional `--name` sets **this worker's name** — the `workerName` it
212
+ registers under at the broker (`‹name›:‹jobType›`) and how it shows up in
213
+ supervisor status/logs. Omit it and a distinct `‹host›-‹profile›-‹random›`
214
+ name is generated, so two `work reviewer` processes never collide at the
215
+ broker. (`--name` names the worker; the profile to run is always the
216
+ positional argument.)
217
+
210
218
  ### Live profile reload (no restart on `assign`)
211
219
 
212
220
  A running `c8ctl nano work <name>` **watches** the profile it is servicing. When
@@ -436,6 +444,64 @@ than `--min-free-mb` MB free (default `1024`).
436
444
  > are frozen so the [nano-ide element-template pack](https://github.com/jwulf/nano-ide/issues/37)
437
445
  > can be built against this contract.
438
446
 
447
+ ## Supervising a fleet of workers: `supervisor`
448
+
449
+ Running several workers means several `nano work` foreground processes — one
450
+ terminal each, none of them restarted if they crash. The **`supervisor`** runs
451
+ and manages a whole fleet from a **single terminal**: a detached daemon spawns
452
+ one `nano work <profile>` child per worker, restarts a crashed child with capped
453
+ backoff, and is driven either interactively (a console you can **detach from**,
454
+ leaving it running) or non-interactively with plain subcommands.
455
+
456
+ ```bash
457
+ # Start a detached supervisor managing several workers at once
458
+ c8ctl nano supervisor start --worker reviewer --worker coder --worker decider
459
+
460
+ # Attach an interactive console (starts the daemon if needed).
461
+ # Detach with `detach` or Ctrl-D — the daemon KEEPS RUNNING. `stop` tears it down.
462
+ c8ctl nano supervisor
463
+
464
+ # Manage the fleet without the console (any terminal, any time):
465
+ c8ctl nano supervisor status # id, state, pid, restarts, uptime
466
+ c8ctl nano supervisor add reviewer --max-parallel 2 # add + spawn a worker (forwards work flags)
467
+ c8ctl nano supervisor add reviewer --name reviewer-2 # a SECOND reviewer, named so it stays distinct
468
+ c8ctl nano supervisor restart reviewer # by worker id or profile name
469
+ c8ctl nano supervisor remove coder # stop + drop a worker (also: `all`)
470
+ c8ctl nano supervisor logs reviewer --follow # tail a worker's log (or the daemon's)
471
+ c8ctl nano supervisor stop # stop the daemon and every worker
472
+ ```
473
+
474
+ Each worker has a **name** — its supervisor id and the broker `workerName` it
475
+ registers under. Pass `--name` on `supervisor add` (or `work`) to set it;
476
+ omit it and one is auto-generated as `‹host›-‹profile›-‹random›`, so you can
477
+ run **several instances of the same profile** and they stay distinct
478
+ end-to-end (status, logs, and at the broker). `restart`/`remove` accept either
479
+ a worker id **or** a profile name — targeting a profile affects *every*
480
+ instance of it.
481
+
482
+ Each worker takes the **same flags as `nano work`** (`--max-parallel`,
483
+ `--job-timeout`, `--lock-grace`, `--poll-timeout`, `--sandbox`/`--image`,
484
+ `--job-type`, `--env`, `--arg`, …); they are forwarded verbatim to the spawned
485
+ child, so a supervised worker is byte-identical to a hand-run `nano work`. In the
486
+ interactive console, type the flags after the profile: `add reviewer --max-parallel 2`.
487
+
488
+ How it works and where things live:
489
+
490
+ - The daemon runs **detached + `unref`'d** (like `nano start` nodes), so it
491
+ outlives the CLI invocation that launched it — that is what "detach" means.
492
+ - A JSON state file `supervisor.json` records `{ pid, socket, workers:[…] }`;
493
+ management commands talk to the daemon over a **control socket** (a Unix domain
494
+ socket, or a named pipe on Windows) and fall back to the state file when the
495
+ socket is unreachable (to report a stale/dead daemon).
496
+ - Per-worker and daemon logs live under `logs/supervisor/` in the state home
497
+ (`worker-<id>.log`, `daemon.log`).
498
+ - **Restart policy:** a crashed child is restarted with exponential backoff
499
+ (1s → 30s cap); a child that stayed up ≥60s resets its backoff. `remove`/`stop`
500
+ cancel any pending restart, and a `restart` cleanly swaps the child (a late
501
+ exit from the old process is never mis-counted against the new one).
502
+ - Stopping is SIGTERM → grace → SIGKILL, per worker and for the daemon; `stop`
503
+ always clears `supervisor.json` so a stale marker never wedges a future start.
504
+
439
505
  ## Cleaning up disk
440
506
 
441
507
  ```bash