@start9labs/start-sdk 2.0.2 → 2.0.4
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.
- package/CHANGELOG.md +37 -4
- package/README.md +10 -10
- package/eslint.config.base.mjs +6 -1
- package/lib/StartSdk.d.ts +18 -10
- package/lib/StartSdk.js +17 -9
- package/lib/StartSdk.js.map +1 -1
- package/lib/mainFn/CommandController.d.ts +2 -1
- package/lib/mainFn/CommandController.js +2 -1
- package/lib/mainFn/CommandController.js.map +1 -1
- package/lib/mainFn/Daemon.d.ts +43 -12
- package/lib/mainFn/Daemon.js +45 -15
- package/lib/mainFn/Daemon.js.map +1 -1
- package/lib/mainFn/Daemons.d.ts +15 -2
- package/lib/mainFn/Daemons.js +16 -3
- package/lib/mainFn/Daemons.js.map +1 -1
- package/lib/mainFn/HealthDaemon.d.ts +2 -0
- package/lib/mainFn/HealthDaemon.js +35 -3
- package/lib/mainFn/HealthDaemon.js.map +1 -1
- package/lib/mainFn/index.d.ts +6 -2
- package/lib/mainFn/index.js +5 -0
- package/lib/mainFn/index.js.map +1 -1
- package/lib/test/output.sdk.d.ts +6 -6
- package/node_modules/@start9labs/start-core/osBindings/BackupTarget.d.ts +2 -2
- package/node_modules/@start9labs/start-core/osBindings/CifsBackupTarget.d.ts +2 -2
- package/node_modules/@start9labs/start-core/osBindings/PartitionInfo.d.ts +2 -2
- package/node_modules/@start9labs/start-core/osBindings/ServerInfo.d.ts +0 -1
- package/node_modules/@start9labs/start-core/osBindings/StartOsRecoveryInfo.d.ts +4 -2
- package/node_modules/@start9labs/start-core/osBindings/index.d.ts +26 -27
- package/node_modules/@start9labs/start-core/osBindings/index.js.map +1 -1
- package/node_modules/@start9labs/start-core/osBindings/tunnel/index.d.ts +3 -3
- package/node_modules/@start9labs/start-core/package.json +0 -7
- package/node_modules/@start9labs/start-core/zExport.js +44 -45
- package/package.json +1 -8
- package/node_modules/@start9labs/start-core/osBindings/LegacyBackupInfo.d.ts +0 -8
- package/node_modules/@start9labs/start-core/osBindings/LegacyBackupInfo.js +0 -4
- package/node_modules/@start9labs/start-core/osBindings/LegacyBackupInfo.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.4 — StartOS 0.4.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`Daemons.dynamic` now composes with `setupMain` instead of replacing it.** `main` is always `sdk.setupMain(...)`; what varies is the `DaemonBuildable` you return from it — a static `sdk.Daemons.of(...)` chain, or the reconciler for a runtime-varying daemon set. The OS ABI has always said as much (`ExpectedExports.main` returns a `DaemonBuildable`, and **both** `Daemons` and `DaemonsReconciler` implement it), but two signatures made that composition unwritable: `setupMain` demanded a `Daemons` rather than the ABI's `DaemonBuildable`, and `Daemons.dynamic(fn)` returned a `main` export — burying the `DaemonsReconciler` it constructs inside a closure. The only shape that compiled was the wrong one: replace `main` with `Daemons.dynamic(...)`, then nest `Daemons.of()` inside its builder. Packages adopting dynamic daemons were funnelled straight into it. Now:
|
|
8
|
+
- **Breaking — `Daemons.dynamic` takes `effects` and returns the reconciler:** `sdk.Daemons.dynamic(effects, fn): DaemonsReconciler` (was `sdk.Daemons.dynamic(fn): main`). Return it from `setupMain`.
|
|
9
|
+
- `setupMain`'s callback is widened to the ABI: it accepts any `T.DaemonBuildable`.
|
|
10
|
+
|
|
11
|
+
Migration — wrap the builder in `setupMain` and pass `effects`:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// before (2.0.0–2.0.3)
|
|
15
|
+
export const main = sdk.Daemons.dynamic(async ({ effects }) => {
|
|
16
|
+
return sdk.Daemons.of(effects).addDaemon(...)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
// after
|
|
20
|
+
export const main = sdk.setupMain(async ({ effects }) => {
|
|
21
|
+
return sdk.Daemons.dynamic(effects, async ({ effects }) => {
|
|
22
|
+
return sdk.Daemons.of(effects).addDaemon(...)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Reconcile semantics are unchanged: inside the builder, `constRetry` reruns-and-reconciles rather than firing `effects.restart()`, so a watched-state change touches only the daemons whose `configHash` moved and the service stays `running`. Reported in [#3470](https://github.com/Start9Labs/start-technologies/issues/3470)
|
|
28
|
+
|
|
29
|
+
## 2.0.3 — StartOS 0.4.0-beta.10 (2026-07-08)
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- **A dependency-gated daemon no longer wedges permanently after its dependency's readiness flaps.** Since 2.0.0's hold/release refactor, `Daemon.term()` unconditionally destroyed the daemon's `SubContainer`, and `HealthDaemon` calls `term()` every time a dependency goes not-ready. When the dependency's health then recovered, the daemon's `start()` called `hold()` on the already-destroyed subcontainer and threw `cannot hold subcontainer …: already destroyed`. Because that `start()` was un-awaited, it surfaced as an unhandled rejection and the daemon never recovered — the health check reported "not ready" / "daemon crashed" indefinitely, curable only by a full package restart. Any service with a dependency-gated daemon was exposed (e.g. `c-lightning`'s and BTCPay's web UIs). The 2.0.0 refactor had removed the `destroySubcontainer` flag that previously kept the subcontainer alive across a stop, collapsing "pause" and "teardown" into one destroying `term()`. This restores the distinction under the hold/release model: `Daemon` gains a non-destroying **`stop()`** (aborts the loop, terminates the process, releases the hold — but leaves the `SubContainer` intact so a later `start()` re-holds it), and `HealthDaemon.changeRunning(false)` now calls `stop()` for a dependency-driven pause. `Daemon.term()` (used by `HealthDaemon.term()` and `Daemons.term()` for genuine teardown) still releases the hold and destroys the subcontainer. `HealthDaemon.changeRunning(true)` additionally awaits and catches `start()`, so a start failure becomes a health failure rather than a silent unhandled-rejection wedge
|
|
34
|
+
- **Dependency-driven pause/resume transitions are now serialized.** `HealthDaemon.updateStatus()` runs fire-and-forget from dependency watchers, so a fast readiness flap (not-ready → ready before the pause's `stop()` finished draining the process) could overlap the pause with the following resume. Because `Daemon.start()` is a no-op while the previous run loop is still winding down, the resume's `start()` could silently do nothing and leave the daemon stopped while the health session believed it was running — the same class of wedge, reachable via a fast flap. `HealthDaemon` now applies pause/resume transitions on an in-order promise chain, so a resume always waits for the in-flight pause to complete before re-holding and restarting
|
|
35
|
+
|
|
3
36
|
## 2.0.2 — StartOS 0.4.0-beta.10 (2026-07-08)
|
|
4
37
|
|
|
5
38
|
### Changed
|
|
@@ -17,7 +50,7 @@
|
|
|
17
50
|
### Added
|
|
18
51
|
|
|
19
52
|
- `addSsl.upstreamCertValidation` controls how the OS reverse proxy validates the container's TLS certificate when it **rewraps SSL** (`addSsl` set AND the protocol's `secure.ssl === true`, e.g. `https`/`wss` — the OS terminates the client's TLS and opens a fresh TLS connection to the container). Omitted (the default) validates against the StartOS root CA, unchanged from before. `'disable'` skips validation entirely — for containers serving a self-signed cert on the trusted internal bridge. `{ certificate: '<pem>' }` validates against a supplied PEM certificate/chain instead of the root CA. Set it through `bindPort`'s `addSsl`, e.g. `multi.bindPort(443, { protocol: 'https', addSsl: { upstreamCertValidation: 'disable' } })`. Exported as `UpstreamCertValidation`
|
|
20
|
-
- **Init progress reporting via `FullProgressTracker` (auto-syncing).** Service code never calls a progress effect — and usually never calls `sync()` either. The init harness builds one root `FullProgressTracker` with the effects context baked in and passes it to every init handler as a third argument: `setupOnInit(async (effects, kind, progress) => …)`. Each handler adds its own phases (with its own names) to the shared tracker, unaware of the others. Add phases and update them (`phase.setTotal/setDone/complete`); **every update auto-reports in the background** to the "Installing" / "Updating" phase of the install. Auto-sync is coalesced — at most one report in flight and one queued, so a burst of updates collapses to the latest snapshot and promises never stack up. `tracker.sync()` is now an explicit
|
|
53
|
+
- **Init progress reporting via `FullProgressTracker` (auto-syncing).** Service code never calls a progress effect — and usually never calls `sync()` either. The init harness builds one root `FullProgressTracker` with the effects context baked in and passes it to every init handler as a third argument: `setupOnInit(async (effects, kind, progress) => …)`. Each handler adds its own phases (with its own names) to the shared tracker, unaware of the others. Add phases and update them (`phase.setTotal/setDone/complete`); **every update auto-reports in the background** to the "Installing" / "Updating" phase of the install. Auto-sync is coalesced — at most one report in flight and one queued, so a burst of updates collapses to the latest snapshot and promises never stack up. `tracker.sync()` is now an explicit _flush_ (no args) that resolves once in-flight + queued reports have drained; the harness calls it before returning. Migrations receive the same tracker via `migrations.up`/`down`/`other` opts (`async ({ effects, progress }) => …`). A handler that didn't keep what `addPhase`/`addNestedPhase` returned can fetch it back by name with `tracker.getPhase(name)` (a `PhaseHandle` or, for a nested phase, a `FullProgressTracker`). `FullProgressTracker` is exported from `utils` (`utils.FullProgressTracker`). The underlying `effects.setInitProgress` / `effects.setBackupProgress` remain but are internal
|
|
21
54
|
- **Backup/restore progress mirrors the same structure.** `Backups.createBackup` and `restoreBackup` build an auto-syncing `FullProgressTracker` instead of calling the effect directly. The pre/post backup and restore hooks (`setPreBackup`, `setPostBackup`, `setPreRestore`, `setPostRestore`) now receive a `FullProgressTracker` as a second argument so custom work (DB dumps, etc.) can report sub-progress; restore progress flows through the init tracker since restore runs during init. Existing hooks that ignore the new argument keep working
|
|
22
55
|
- `PgDumpConfig.readyTimeout` / `MysqlDumpConfig.readyTimeout` make the post-start readiness wait in `Backups.withPgDump` / `Backups.withMysqlDump` configurable (milliseconds, matching the `gracePeriod` / `sigtermTimeout` convention; defaults 60000 Postgres / 30000 MySQL/MariaDB — unchanged from before). Each dump helper boots a throwaway DB server against the volume and polls until it accepts connections; a large or crash-recovering data directory can exceed the old hard-coded ceiling and fail the backup with "failed to become ready within N seconds" even though the live daemon — which gets a far longer `gracePeriod` — starts fine. Raise it to match, e.g. `withMysqlDump({ …, readyTimeout: 180000 })`
|
|
23
56
|
- `userspaceFilesystems` and `virtualNetworking` manifest flags split the former `nestedRuntime` flag into its two independent device grants. `userspaceFilesystems` mounts `/dev/fuse` for fuse-overlayfs storage (the rootless driver behind a nested OCI runtime). `virtualNetworking` mounts `/dev/net/tun` so a service can bring up kernel tun interfaces for VPN / WireGuard / tun-class workloads. The service LXC already retains `CAP_NET_ADMIN` within its user namespace via the standard `userns.conf` include, so no extra capability machinery is required — only the device node was missing
|
|
@@ -34,16 +67,16 @@
|
|
|
34
67
|
|
|
35
68
|
### Changed
|
|
36
69
|
|
|
37
|
-
- **Breaking — `sdk.SubContainer.of(...)` is now lazy by default.** Returns a `SubContainerLazy<M>`
|
|
70
|
+
- **Breaking — `sdk.SubContainer.of(...)` is now lazy by default.** Returns a `SubContainerLazy<M>` _synchronously_ (no `Promise<>` wrapper) whose filesystem is materialized on first method call. `rootfs` / `guid` / `subpath()` on the unified `SubContainer<M>` interface widen to `T | Promise<T>`; the concrete classes narrow (`SubContainerEager` to `T`, `SubContainerLazy` to `Promise<T>`). Code holding the generic interface must `await` those accessors; code holding `SubContainerEager` keeps sync access. Migration: most callers already use only async methods (`.exec`, `.writeFile`, `.spawn`, `.launch`) and need no change beyond dropping the redundant `await` on `SubContainer.of(...)`; callers that read `.rootfs` / `.guid` / `.subpath()` add an `await` or switch to `sdk.SubContainer.eager(...)`. The lazy default enables `Daemons.dynamic`'s "leave alone is load-bearing" guarantee: unchanged daemons across reconciles never materialize a fresh subcontainer
|
|
38
71
|
- **Breaking — `SubContainerOwned` / `SubContainerRc` collapsed into `SubContainerEager`.** The reference-counted handle (`SubContainerRc`, `.rc()`, `.isOwned()`) is replaced by an internal hold-count on the unified `SubContainer`. Multiple consumers each call `sub.hold()` (returns a release fn); the container's `destroyFs` fires when `destroy()` has been called and the last hold is released, in either order. `Daemon.start()` takes its own hold for the daemon's lifetime and releases it on `term()`. The `destroySubcontainer` flag on `Daemon.term` / `HealthDaemon.term` is gone — `Daemons.term()` calls `destroy()` on each unique subcontainer in its entries, and the hold machinery handles sharing safely
|
|
39
72
|
- **Breaking — `Daemon.sharesSubcontainerWith` removed.** Two `Daemon`s share a subcontainer when constructed with the same `SubContainer` instance (compare `daemon.subcontainer.identity`). Daemons' internal "should I destroy this subc?" branching is gone — it always calls `destroy()`, and hold-count decides
|
|
40
73
|
- **Breaking — `Daemons` is record-then-materialize.** `.addDaemon()` / `.addOneshot()` / `.addHealthCheck()` append a recorded entry without constructing `HealthDaemon` or `Daemon`. `Daemons.build()` walks the entries and constructs the chain in one pass. Functionally identical for `setupMain` callers — the original "construct on addDaemon, kick off on build" timing is invisible because nothing actually starts until `build()`'s `updateStatus()` calls anyway. The change is load-bearing for `Daemons.dynamic`, which needs to diff entries without paying the cost of building them eagerly each reconcile
|
|
41
74
|
- **Breaking — `SubContainer` adds `identity: symbol`.** Sync, stable handle preserved across `SubContainerLazy.eager()` materialization. Use for sharing checks that must work before materialization (replaces `Daemon.sharesSubcontainerWith`'s previous `guid` comparison, which couldn't fire pre-materialization)
|
|
42
75
|
- Container-runtime updated: `SubContainerOwned` → `SubContainer.eager`; `SubContainerRc<M>` → `SubContainer<M>`; `daemon.subcontainerRc()` → `daemon.subcontainer`
|
|
43
|
-
- **zod bumped `4.3.6` → `4.4.3`** (it was emergency-pinned to exactly `4.3.6` in 1.4.1). zod 4.4.0 tightened object parsing so a required key wrapped in `.catch()` threw `"expected nonoptional, received undefined"` on a
|
|
76
|
+
- **zod bumped `4.3.6` → `4.4.3`** (it was emergency-pinned to exactly `4.3.6` in 1.4.1). zod 4.4.0 tightened object parsing so a required key wrapped in `.catch()` threw `"expected nonoptional, received undefined"` on a _missing_ key — which broke the SDK at import (`actions/input/inputSpecConstants.ts` parses its SMTP shapes at module load) and the `.merge({})` seed pattern that every FileHelper-based package relies on. zod **4.4.3** (#5939, #5941) restores the 4.3.6 behavior, so the pin is exactly `4.4.3` — **not** `^4.4.0`, which would admit the still-broken 4.4.0–4.4.2. The `zExport` loose-object patch and FileHelper are unaffected (verified against the shipped build). Downstream: packages taking SDK 2.0 inherit zod 4.4.3 transitively and need **no** schema change for the catch-on-missing case; the other cumulative 4.4.0 fixes (stricter `z.base64()` / `z.httpUrl()`, `.merge()` throwing on schemas with refinements, materialized tuple defaults) may surface as `tsc` errors only in packages that use those specific APIs
|
|
44
77
|
- **TypeScript bumped `^5.9.3` → `^6.0.3`, and the build migrated off the deprecated `moduleResolution: "node"` (node10).** TS 6.0 deprecates node10 resolution (removed entirely in TS 7.0). The SDK's own `base` / `package` tsconfigs now use `moduleResolution: "bundler"` (keeping `module: "commonjs"` — emitted CJS is byte-identical and the published `.d.ts` API surface is unchanged) plus an explicit `rootDir` (TS 6.0 changed the default to the tsconfig directory). The shipped `tsconfig.base.json` that packages `extends` now uses `target: "ES2022"`, `moduleResolution: "bundler"` + `module: "preserve"`, `types: ["node"]`, and `rootDir: "${configDir}"`, so a package needs only `extends` + `include` and nothing else: node globals are not auto-included under bundler resolution; the prior `ES2018` target predated `Object.fromEntries` and other ES2019+ lib APIs packages rely on; and TS 6.0 requires an explicit `rootDir` for the `ncc` emit (the `${configDir}` template resolves to each extending package's own directory). Putting the fleet on modern resolution before TS 7, no SDK source changes were required
|
|
45
78
|
- **Breaking — `input-not-matches` task input split into `accept` (a list) and `set`.** `TaskInput` was `{ kind: 'partial', value }`, where the single `value` both decided whether the task was satisfied (the current action input had to be a superset of it) and prefilled the action form when the user ran the task. It is now `{ kind: 'partial', accept: DeepPartial<Input>[], set: DeepPartial<Input> }`: the task is satisfied when the current input matches **any** entry in `accept`, and when none match the task is shown and prefills `set`. This lets a package accept several already-good configurations while still pushing a single recommended value when none of them hold — e.g. accept either of two valid network modes, but set the preferred one otherwise. The cross-package critical-conflict guard now activates only when the input conflicts with **every** `accept` entry. Migration: replace `value: X` with `accept: [X], set: X` for identical behavior to 1.x. Already-published s9pks built against the pre-2.0 SDK keep working without a rebuild — the StartOS host still accepts the legacy `{ kind: 'partial', value }` payload over the effects socket and normalizes it to `accept: [value], set: value`
|
|
46
|
-
- **Breaking (internal) — zod loose-object handling unified onto a single `z` export; the global `require.cache` patch was removed.** The SDK makes `z.object()` preserve unknown keys (so `FileHelper` models that declare only a subset of a config file round-trip the rest). This was previously done by
|
|
79
|
+
- **Breaking (internal) — zod loose-object handling unified onto a single `z` export; the global `require.cache` patch was removed.** The SDK makes `z.object()` preserve unknown keys (so `FileHelper` models that declare only a subset of a config file round-trip the rest). This was previously done by _two_ mechanisms: a shadow `z` (the one exported from `@start9labs/start-sdk`) plus a walk over Node's `require.cache` that mutated the raw `zod` module so the SDK's own internals — which `import { z } from 'zod'` — also got loose objects. The cache walk was fragile (it duck-typed the module cache and silently no-op'd outside CommonJS). It is removed: the SDK's internal modules now import `z` from the shadow directly, and `FileHelper`'s structured factories (`json` / `yaml` / `toml` / `ini` / `env` / `xml`) now deep-loosen their shape explicitly via `z.deepLoose(shape)`, making unknown-key preservation a property of the file-model boundary rather than a global default. **Packaging code is unaffected:** `import { z } from '@start9labs/start-sdk'` still yields loose-by-default objects and every package's file models keep preserving undeclared on-disk keys. The only behavioral change is for code that imported `z` directly from `zod` and relied on the SDK to have patched it — it must import `z` from `@start9labs/start-sdk` instead. No StartOS packaging code does this (only vendored upstream application sources import `zod` directly, and they use their own copy)
|
|
47
80
|
|
|
48
81
|
- **Breaking — service interfaces moved onto their binding; `sdk.serviceInterface.*` accessors replaced by `sdk.host.*`.** A service interface is no longer a flat entry on `PackageDataEntry.serviceInterfaces` (that field is removed) — it now lives on the binding that exported it: `Host.bindings[internalPort].interfaces` (a `ServiceInterfaceId`-keyed map; a port may back several) for single-port `Origin.export`, and `Host.bindingRanges[internalStartPort].interface` for a range's `RangeOrigin.export`. Correspondingly the SDK drops `sdk.serviceInterface.{getOwn, get, getAllOwn, getAll}` and adds `sdk.host.getOwn(effects, hostId)` / `sdk.host.get(effects, { hostId, packageId? })`, which return the reactive `Host` (same `const`/`once`/`watch`/`onChange`/`waitFor` read strategies). Both accessors take an optional `map` (and `eq`, default deep-equal) selector — matching the old `sdk.serviceInterface.*` — so `const()` can re-run on a change to a single child attr of the host rather than wholesale on the entire host. Reach an interface by walking the host — `Object.values(host.bindings).flatMap(b => Object.values(b.interfaces))` (or `host.bindingRanges[start].interface`). Each single-port interface's `addressInfo` comes back **already filled** — carrying the `filter`/`format`/`nonLocal`/`public`/`bridge`/`toUrl` helpers directly (e.g. `iface.addressInfo.format('url')`), so no separate `utils.filledAddress(host, …)` call is needed. The win: a binding's host is now reachable even when it exports no interface.
|
|
49
82
|
|
package/README.md
CHANGED
|
@@ -49,32 +49,31 @@ From there, `sdk` exposes the full toolkit:
|
|
|
49
49
|
```typescript
|
|
50
50
|
// Define daemons
|
|
51
51
|
export const main = sdk.setupMain(async ({ effects }) =>
|
|
52
|
-
sdk.Daemons.of(effects)
|
|
53
|
-
|
|
52
|
+
sdk.Daemons.of(effects).addDaemon('primary', {
|
|
53
|
+
/* ... */
|
|
54
|
+
}),
|
|
54
55
|
)
|
|
55
56
|
|
|
56
57
|
// Define actions
|
|
57
|
-
export const setName = sdk.Action.withInput('set-name'
|
|
58
|
+
export const setName = sdk.Action.withInput('set-name' /* ... */)
|
|
58
59
|
|
|
59
60
|
// Define interfaces
|
|
60
61
|
export const setInterfaces = sdk.setupInterfaces(async ({ effects }) => {
|
|
61
62
|
const multi = sdk.MultiHost.of(effects, 'web')
|
|
62
63
|
const origin = await multi.bindPort(80, { protocol: 'http' })
|
|
63
|
-
const ui = sdk.createInterface(effects, { name: 'Web UI', id: 'ui'
|
|
64
|
+
const ui = sdk.createInterface(effects, { name: 'Web UI', id: 'ui' /* ... */ })
|
|
64
65
|
return [await origin.export([ui])]
|
|
65
66
|
})
|
|
66
67
|
|
|
67
68
|
// Define backups
|
|
68
|
-
export const { createBackup, restoreBackup } = sdk.setupBackups(
|
|
69
|
-
async () => sdk.Backups.ofVolumes('main')
|
|
70
|
-
)
|
|
69
|
+
export const { createBackup, restoreBackup } = sdk.setupBackups(async () => sdk.Backups.ofVolumes('main'))
|
|
71
70
|
```
|
|
72
71
|
|
|
73
72
|
## Packages
|
|
74
73
|
|
|
75
|
-
| Source
|
|
76
|
-
|
|
77
|
-
| `projects/start-sdk/lib/`
|
|
74
|
+
| Source | npm | Description |
|
|
75
|
+
| ------------------------------------ | ------------------------ | --------------------------------------------------------------------------------------------------- |
|
|
76
|
+
| `projects/start-sdk/lib/` | `@start9labs/start-sdk` | Full SDK for service developers (the one package you install) |
|
|
78
77
|
| `shared-libs/ts-modules/start-core/` | `@start9labs/start-core` | Core types, ABI definitions, and effects interface — bundled into the SDK, not published separately |
|
|
79
78
|
|
|
80
79
|
The published package also ships `s9pk.mk` and `tsconfig.base.json` at its root, so a service package consumes the canonical build plumbing by reference: `include node_modules/@start9labs/start-sdk/s9pk.mk` in its `Makefile` and `"extends": "@start9labs/start-sdk/tsconfig.base.json"` in its `tsconfig.json`.
|
|
@@ -86,6 +85,7 @@ For comprehensive packaging guides, tutorials, and API reference:
|
|
|
86
85
|
**[docs.start9.com/packaging](https://docs.start9.com/packaging)**
|
|
87
86
|
|
|
88
87
|
The packaging docs cover:
|
|
88
|
+
|
|
89
89
|
- Environment setup and prerequisites
|
|
90
90
|
- Project structure and conventions
|
|
91
91
|
- Manifest, main, interfaces, actions, and all other service modules
|
package/eslint.config.base.mjs
CHANGED
|
@@ -15,7 +15,12 @@ export default tseslint.config({
|
|
|
15
15
|
// `${sub.rootfs}` where rootfs is Promise<string> -> "[object Promise]"
|
|
16
16
|
'@typescript-eslint/restrict-template-expressions': [
|
|
17
17
|
'error',
|
|
18
|
-
{
|
|
18
|
+
{
|
|
19
|
+
allowNumber: true,
|
|
20
|
+
allowBoolean: true,
|
|
21
|
+
allowNullish: true,
|
|
22
|
+
allowRegExp: true,
|
|
23
|
+
},
|
|
19
24
|
],
|
|
20
25
|
},
|
|
21
26
|
})
|
package/lib/StartSdk.d.ts
CHANGED
|
@@ -2829,13 +2829,16 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
|
|
|
2829
2829
|
*/
|
|
2830
2830
|
setupInterfaces: import("@start9labs/start-core/interfaces/setupInterfaces").SetupServiceInterfaces;
|
|
2831
2831
|
/**
|
|
2832
|
-
* Define the main entrypoint for the service.
|
|
2833
|
-
*
|
|
2834
|
-
*
|
|
2832
|
+
* Define the main entrypoint for the service. `main` is always `setupMain`.
|
|
2833
|
+
* The provided function returns the daemon topology: either a static
|
|
2834
|
+
* `sdk.Daemons.of(effects).addDaemon(...)` chain, or — for a daemon set that
|
|
2835
|
+
* changes at runtime — the reconciler from
|
|
2836
|
+
* `sdk.Daemons.dynamic(effects, fn)`. Both are `T.DaemonBuildable`.
|
|
2837
|
+
* @param fn - Async function that receives `effects` and returns a `Daemons` chain or a `DaemonsReconciler`
|
|
2835
2838
|
*/
|
|
2836
2839
|
setupMain: (fn: (o: {
|
|
2837
2840
|
effects: Effects;
|
|
2838
|
-
}) => Promise<
|
|
2841
|
+
}) => Promise<T.DaemonBuildable>) => T.ExpectedExports.main;
|
|
2839
2842
|
/**
|
|
2840
2843
|
* Built-in trigger strategies that control how often a health check polls.
|
|
2841
2844
|
*
|
|
@@ -2940,16 +2943,21 @@ export declare class StartSdk<Manifest extends T.SDKManifest> {
|
|
|
2940
2943
|
*/
|
|
2941
2944
|
of(effects: Effects): Daemons<Manifest, never>;
|
|
2942
2945
|
/**
|
|
2943
|
-
* Build a
|
|
2944
|
-
*
|
|
2945
|
-
*
|
|
2946
|
-
* `fn`'s subcontainers must be lazy (`sdk.SubContainer.of(...)`).
|
|
2946
|
+
* Build a reconciler whose daemon set is a function of on-disk state:
|
|
2947
|
+
* it diffs `fn`'s freshly-built `Daemons` chain against the running set
|
|
2948
|
+
* on every `effects.constRetry` trigger, touching only what changed.
|
|
2947
2949
|
*
|
|
2950
|
+
* Return it from `setupMain` — it is a `T.DaemonBuildable`, just like a
|
|
2951
|
+
* static `sdk.Daemons.of(...)` chain. See {@link Daemons.dynamic} for
|
|
2952
|
+
* diff semantics and the rule that `fn`'s subcontainers must be lazy
|
|
2953
|
+
* (`sdk.SubContainer.of(...)`).
|
|
2954
|
+
*
|
|
2955
|
+
* @param effects The effects context, from `setupMain`
|
|
2948
2956
|
* @param fn Async builder invoked on startup and on every constRetry
|
|
2949
2957
|
*/
|
|
2950
|
-
dynamic(fn: (o: {
|
|
2958
|
+
dynamic(effects: Effects, fn: (o: {
|
|
2951
2959
|
effects: Effects;
|
|
2952
|
-
}) => Promise<Daemons<Manifest, any>> | Daemons<Manifest, any>):
|
|
2960
|
+
}) => Promise<Daemons<Manifest, any>> | Daemons<Manifest, any>): import(".").DaemonsReconciler<Manifest>;
|
|
2953
2961
|
};
|
|
2954
2962
|
SubContainer: {
|
|
2955
2963
|
/**
|
package/lib/StartSdk.js
CHANGED
|
@@ -660,9 +660,12 @@ class StartSdk {
|
|
|
660
660
|
*/
|
|
661
661
|
setupInterfaces: setupInterfaces_1.setupServiceInterfaces,
|
|
662
662
|
/**
|
|
663
|
-
* Define the main entrypoint for the service.
|
|
664
|
-
*
|
|
665
|
-
*
|
|
663
|
+
* Define the main entrypoint for the service. `main` is always `setupMain`.
|
|
664
|
+
* The provided function returns the daemon topology: either a static
|
|
665
|
+
* `sdk.Daemons.of(effects).addDaemon(...)` chain, or — for a daemon set that
|
|
666
|
+
* changes at runtime — the reconciler from
|
|
667
|
+
* `sdk.Daemons.dynamic(effects, fn)`. Both are `T.DaemonBuildable`.
|
|
668
|
+
* @param fn - Async function that receives `effects` and returns a `Daemons` chain or a `DaemonsReconciler`
|
|
666
669
|
*/
|
|
667
670
|
setupMain: (fn) => (0, mainFn_1.setupMain)(fn),
|
|
668
671
|
/**
|
|
@@ -773,15 +776,20 @@ class StartSdk {
|
|
|
773
776
|
return Daemons_1.Daemons.of({ effects });
|
|
774
777
|
},
|
|
775
778
|
/**
|
|
776
|
-
* Build a
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
* `fn`'s subcontainers must be lazy (`sdk.SubContainer.of(...)`).
|
|
779
|
+
* Build a reconciler whose daemon set is a function of on-disk state:
|
|
780
|
+
* it diffs `fn`'s freshly-built `Daemons` chain against the running set
|
|
781
|
+
* on every `effects.constRetry` trigger, touching only what changed.
|
|
780
782
|
*
|
|
783
|
+
* Return it from `setupMain` — it is a `T.DaemonBuildable`, just like a
|
|
784
|
+
* static `sdk.Daemons.of(...)` chain. See {@link Daemons.dynamic} for
|
|
785
|
+
* diff semantics and the rule that `fn`'s subcontainers must be lazy
|
|
786
|
+
* (`sdk.SubContainer.of(...)`).
|
|
787
|
+
*
|
|
788
|
+
* @param effects The effects context, from `setupMain`
|
|
781
789
|
* @param fn Async builder invoked on startup and on every constRetry
|
|
782
790
|
*/
|
|
783
|
-
dynamic(fn) {
|
|
784
|
-
return Daemons_1.Daemons.dynamic(fn);
|
|
791
|
+
dynamic(effects, fn) {
|
|
792
|
+
return Daemons_1.Daemons.dynamic(effects, fn);
|
|
785
793
|
},
|
|
786
794
|
},
|
|
787
795
|
SubContainer: {
|
package/lib/StartSdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartSdk.js","sourceRoot":"","sources":["../../lib/StartSdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StartSdk.js","sourceRoot":"","sources":["../../lib/StartSdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+jCA,gCA8CC;AA7mCD,qDAAsC;AACtC,wEAAyD;AACzD,sFAAkF;AAClF,4EAAwE;AACxE,8EAA0E;AAC1E,oFAAgF;AAChF,gGAKgE;AAChE,8EAMoD;AACpD,mFAGyD;AACzD,6FAI8D;AAC9D,wDAA8D;AAC9D,wDAKqC;AACrC,iEAA0E;AAC1E,mGAA+F;AAC/F,uGAAmG;AACnG,2FAAuF;AACvF,uFAA0F;AAC1F,gEAAiD;AAEjD,+EAA2E;AAC3E,yEAA6E;AAC7E,qEAAiE;AACjE,+EAAgE;AAChE,8CAA0C;AAC1C,wDAAwE;AACxE,gDAAgE;AAChE,6EAAyE;AACzE,qCAAoC;AACpC,8CAAkD;AAClD,4CAAwC;AACxC,uCAA0D;AAC1D,6DAAyD;AACzD,iCAOe;AACf,sDAM4B;AAC5B,0CAA6C;AAC7C,uCAA0D;AAE1D,+DAA+D;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AAC,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YACnC,MAAM,IAAI,wBAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QACvC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -37,7 +37,8 @@ export declare class CommandController<Manifest extends T.SDKManifest, C extends
|
|
|
37
37
|
* Terminate the running command by sending a signal.
|
|
38
38
|
*
|
|
39
39
|
* Sends the specified signal (default: SIGTERM), then escalates to SIGKILL
|
|
40
|
-
* after the timeout expires
|
|
40
|
+
* after the timeout expires, and awaits the process's exit. Does not touch
|
|
41
|
+
* the SubContainer — its lifecycle is owned by {@link Daemon} (`stop`/`term`).
|
|
41
42
|
*
|
|
42
43
|
* @param options.signal - The signal to send (default: SIGTERM)
|
|
43
44
|
* @param options.timeout - Milliseconds before escalating to SIGKILL
|
|
@@ -168,7 +168,8 @@ class CommandController extends util_1.Drop {
|
|
|
168
168
|
* Terminate the running command by sending a signal.
|
|
169
169
|
*
|
|
170
170
|
* Sends the specified signal (default: SIGTERM), then escalates to SIGKILL
|
|
171
|
-
* after the timeout expires
|
|
171
|
+
* after the timeout expires, and awaits the process's exit. Does not touch
|
|
172
|
+
* the SubContainer — its lifecycle is owned by {@link Daemon} (`stop`/`term`).
|
|
172
173
|
*
|
|
173
174
|
* @param options.signal - The signal to send (default: SIGTERM)
|
|
174
175
|
* @param options.timeout - Milliseconds before escalating to SIGKILL
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandController.js","sourceRoot":"","sources":["../../../lib/mainFn/CommandController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAA2C;AAC3C,wDAAkE;AAElE,gEAAiD;AAEjD,kCAA4C;AAE5C,qDAAsC;AAEtC,2EAAuE;AAEvE;;;;;;;;GAQG;AACH,MAA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D;;;OAGG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,kBAAU,EAAE,GAAG,EAAE;QACtC,IAAI,OAAO,GAAG,CAAC;YACb,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,IAAI,EAAE,CAAA;YACb,CAAC,EAAE,OAAO,CAAC,CAAA;QACb,IAAI,CAAC;YACH,IAAI,OAAO,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,YAAY,eAAe;gBACxD,MAAM,OAAO,CAAC,IAAI,CAAC;oBACjB,IAAI,CAAC,aAAa;oBAClB,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CACxB,UAAU,CACR,GAAG,EAAE,CACH,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,EAC/D,OAAO,GAAG,CAAC,CACZ,CACF;iBACF,CAAC,CAAA;;gBACC,MAAM,IAAI,CAAC,aAAa,CAAA;QAC/B,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;gBACvB,IAAI,IAAI,CAAC,OAAO,YAAY,eAAe;oBAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;;oBAC5D,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;IACH,CAAC;IACD
|
|
1
|
+
{"version":3,"file":"CommandController.js","sourceRoot":"","sources":["../../../lib/mainFn/CommandController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAA2C;AAC3C,wDAAkE;AAElE,gEAAiD;AAEjD,kCAA4C;AAE5C,qDAAsC;AAEtC,2EAAuE;AAEvE;;;;;;;;GAQG;AACH,MAAa,iBAGX,SAAQ,WAAI;IACZ,YACW,aAA4B,EAC7B,KAA0B,EACjB,YAAe,EACxB,OAA0C,EACzC,iBAAyB,0BAAuB;QAEz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OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;gBACnC,CAAC,EAAE,OAAO,CAAC,CAAA;YACb,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,KAAK,CACX,yBAAyB,MAAM,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAC7D,CAAA;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,YAAY,eAAe;YACzC,MAAM,OAAO,CAAC,IAAI,CAAC;gBACjB,IAAI,CAAC,aAAa;gBAClB,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CACxB,UAAU,CACR,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC,EACnE,OAAO,GAAG,CAAC,CACZ,CACF;aACF,CAAC,CAAA;;YACC,MAAM,IAAI,CAAC,aAAa,CAAA;IAC/B,CAAC;IACD,MAAM;QACJ,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,2BAAY,CAAC,CAAA;IACjC,CAAC;CACF;AAjMD,8CAiMC"}
|
package/lib/mainFn/Daemon.d.ts
CHANGED
|
@@ -8,10 +8,12 @@ import { Oneshot } from './Oneshot';
|
|
|
8
8
|
* A managed long-running process wrapper around {@link CommandController}.
|
|
9
9
|
*
|
|
10
10
|
* When started, the daemon automatically restarts its underlying command on
|
|
11
|
-
* failure with exponential backoff (up to 30 seconds).
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* failure with exponential backoff (up to 30 seconds). While the daemon is
|
|
12
|
+
* running, it holds a use-token (`subcontainer.hold()`) on its SubContainer
|
|
13
|
+
* so the container is not destroyed out from under it. There are two ways to
|
|
14
|
+
* bring it down: {@link stop} releases the hold but leaves the SubContainer
|
|
15
|
+
* intact so a later {@link start} can resume in it (a restartable pause);
|
|
16
|
+
* {@link term} additionally destroys the SubContainer (genuine teardown).
|
|
15
17
|
*
|
|
16
18
|
* @typeParam Manifest - The service manifest type
|
|
17
19
|
* @typeParam C - The subcontainer type, or `null` for JS-only daemons
|
|
@@ -60,18 +62,47 @@ export declare class Daemon<Manifest extends T.SDKManifest, C extends SubContain
|
|
|
60
62
|
* Start the daemon. If it is already running, this is a no-op.
|
|
61
63
|
*
|
|
62
64
|
* Takes a `hold()` on the daemon's SubContainer (if any) so the container
|
|
63
|
-
* is kept alive while the daemon runs. The hold is released
|
|
64
|
-
* {@link term}. The daemon
|
|
65
|
-
* increasing backoff until `term` is called.
|
|
65
|
+
* is kept alive while the daemon runs. The hold is released by {@link stop}
|
|
66
|
+
* (a restartable pause) or {@link term} (teardown). The daemon automatically
|
|
67
|
+
* restarts on failure with increasing backoff until `stop`/`term` is called.
|
|
66
68
|
*/
|
|
67
69
|
start(): Promise<void>;
|
|
68
70
|
private runLoop;
|
|
69
71
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
72
|
+
* Stop the daemon's process and restart loop and release the SubContainer
|
|
73
|
+
* hold taken at {@link start}, **without** destroying the SubContainer.
|
|
74
|
+
* A subsequent {@link start} re-takes the hold and resumes in the same
|
|
75
|
+
* container.
|
|
76
|
+
*
|
|
77
|
+
* This is the non-destroying counterpart to {@link term}: use it for a
|
|
78
|
+
* temporary stop where the daemon is expected to start again — e.g. a
|
|
79
|
+
* dependency going not-ready. Releasing the hold without requesting
|
|
80
|
+
* destruction leaves the SubContainer alive (its leader keeps `proc/1`),
|
|
81
|
+
* so the restart is cheaper than a destroy + recreate and — as long as
|
|
82
|
+
* nothing else has requested destruction — the next `start()`'s `hold()`
|
|
83
|
+
* succeeds rather than throwing `already destroyed`.
|
|
84
|
+
*
|
|
85
|
+
* Sends the configured signal (default SIGTERM) and waits for the process
|
|
86
|
+
* to exit. Idempotent, and a no-op when the daemon is not running.
|
|
87
|
+
*
|
|
88
|
+
* @param termOptions Optional termination settings
|
|
89
|
+
* @param termOptions.signal The signal to send (default `SIGTERM`)
|
|
90
|
+
* @param termOptions.timeout Milliseconds to wait before escalating to `SIGKILL` (default = `Daemon`'s configured `sigtermTimeout`, ultimately `DEFAULT_SIGTERM_TIMEOUT`)
|
|
91
|
+
*/
|
|
92
|
+
stop(termOptions?: {
|
|
93
|
+
signal?: NodeJS.Signals | undefined;
|
|
94
|
+
timeout?: number | undefined;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Terminate the daemon: {@link stop} it (stop the process, abort the
|
|
98
|
+
* restart loop, release the SubContainer hold taken at {@link start}) and
|
|
99
|
+
* then request the SubContainer's destruction.
|
|
100
|
+
*
|
|
101
|
+
* `destroy()` is idempotent and defers to the last hold release, so other
|
|
102
|
+
* daemons sharing the same SubContainer keep it alive until they also
|
|
103
|
+
* term. Unlike {@link stop}, this is a one-way teardown — a `start()`
|
|
104
|
+
* after `term()` throws `already destroyed`; use {@link stop} for a
|
|
105
|
+
* restartable pause.
|
|
75
106
|
*
|
|
76
107
|
* Sends the configured signal (default SIGTERM) and waits for the
|
|
77
108
|
* process to exit.
|
package/lib/mainFn/Daemon.js
CHANGED
|
@@ -11,10 +11,12 @@ const MAX_TIMEOUT_MS = 30000;
|
|
|
11
11
|
* A managed long-running process wrapper around {@link CommandController}.
|
|
12
12
|
*
|
|
13
13
|
* When started, the daemon automatically restarts its underlying command on
|
|
14
|
-
* failure with exponential backoff (up to 30 seconds).
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* failure with exponential backoff (up to 30 seconds). While the daemon is
|
|
15
|
+
* running, it holds a use-token (`subcontainer.hold()`) on its SubContainer
|
|
16
|
+
* so the container is not destroyed out from under it. There are two ways to
|
|
17
|
+
* bring it down: {@link stop} releases the hold but leaves the SubContainer
|
|
18
|
+
* intact so a later {@link start} can resume in it (a restartable pause);
|
|
19
|
+
* {@link term} additionally destroys the SubContainer (genuine teardown).
|
|
18
20
|
*
|
|
19
21
|
* @typeParam Manifest - The service manifest type
|
|
20
22
|
* @typeParam C - The subcontainer type, or `null` for JS-only daemons
|
|
@@ -85,9 +87,9 @@ class Daemon extends util_1.Drop {
|
|
|
85
87
|
* Start the daemon. If it is already running, this is a no-op.
|
|
86
88
|
*
|
|
87
89
|
* Takes a `hold()` on the daemon's SubContainer (if any) so the container
|
|
88
|
-
* is kept alive while the daemon runs. The hold is released
|
|
89
|
-
* {@link term}. The daemon
|
|
90
|
-
* increasing backoff until `term` is called.
|
|
90
|
+
* is kept alive while the daemon runs. The hold is released by {@link stop}
|
|
91
|
+
* (a restartable pause) or {@link term} (teardown). The daemon automatically
|
|
92
|
+
* restarts on failure with increasing backoff until `stop`/`term` is called.
|
|
91
93
|
*/
|
|
92
94
|
async start() {
|
|
93
95
|
if (this.loop) {
|
|
@@ -158,20 +160,27 @@ class Daemon extends util_1.Drop {
|
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
* keep it alive until they also term).
|
|
163
|
+
* Stop the daemon's process and restart loop and release the SubContainer
|
|
164
|
+
* hold taken at {@link start}, **without** destroying the SubContainer.
|
|
165
|
+
* A subsequent {@link start} re-takes the hold and resumes in the same
|
|
166
|
+
* container.
|
|
166
167
|
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
168
|
+
* This is the non-destroying counterpart to {@link term}: use it for a
|
|
169
|
+
* temporary stop where the daemon is expected to start again — e.g. a
|
|
170
|
+
* dependency going not-ready. Releasing the hold without requesting
|
|
171
|
+
* destruction leaves the SubContainer alive (its leader keeps `proc/1`),
|
|
172
|
+
* so the restart is cheaper than a destroy + recreate and — as long as
|
|
173
|
+
* nothing else has requested destruction — the next `start()`'s `hold()`
|
|
174
|
+
* succeeds rather than throwing `already destroyed`.
|
|
175
|
+
*
|
|
176
|
+
* Sends the configured signal (default SIGTERM) and waits for the process
|
|
177
|
+
* to exit. Idempotent, and a no-op when the daemon is not running.
|
|
169
178
|
*
|
|
170
179
|
* @param termOptions Optional termination settings
|
|
171
180
|
* @param termOptions.signal The signal to send (default `SIGTERM`)
|
|
172
181
|
* @param termOptions.timeout Milliseconds to wait before escalating to `SIGKILL` (default = `Daemon`'s configured `sigtermTimeout`, ultimately `DEFAULT_SIGTERM_TIMEOUT`)
|
|
173
182
|
*/
|
|
174
|
-
async
|
|
183
|
+
async stop(termOptions) {
|
|
175
184
|
this.exitedSuccess = false;
|
|
176
185
|
this.onExitFns = [];
|
|
177
186
|
if (this.loop) {
|
|
@@ -189,6 +198,27 @@ class Daemon extends util_1.Drop {
|
|
|
189
198
|
this.releaseSubcontainerHold = null;
|
|
190
199
|
await release().catch(logErrorOnce_1.logErrorOnce);
|
|
191
200
|
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Terminate the daemon: {@link stop} it (stop the process, abort the
|
|
204
|
+
* restart loop, release the SubContainer hold taken at {@link start}) and
|
|
205
|
+
* then request the SubContainer's destruction.
|
|
206
|
+
*
|
|
207
|
+
* `destroy()` is idempotent and defers to the last hold release, so other
|
|
208
|
+
* daemons sharing the same SubContainer keep it alive until they also
|
|
209
|
+
* term. Unlike {@link stop}, this is a one-way teardown — a `start()`
|
|
210
|
+
* after `term()` throws `already destroyed`; use {@link stop} for a
|
|
211
|
+
* restartable pause.
|
|
212
|
+
*
|
|
213
|
+
* Sends the configured signal (default SIGTERM) and waits for the
|
|
214
|
+
* process to exit.
|
|
215
|
+
*
|
|
216
|
+
* @param termOptions Optional termination settings
|
|
217
|
+
* @param termOptions.signal The signal to send (default `SIGTERM`)
|
|
218
|
+
* @param termOptions.timeout Milliseconds to wait before escalating to `SIGKILL` (default = `Daemon`'s configured `sigtermTimeout`, ultimately `DEFAULT_SIGTERM_TIMEOUT`)
|
|
219
|
+
*/
|
|
220
|
+
async term(termOptions) {
|
|
221
|
+
await this.stop(termOptions);
|
|
192
222
|
// Request the SubContainer's destruction. Idempotent + hold-aware:
|
|
193
223
|
// if another daemon still holds this SubContainer, destroy waits for
|
|
194
224
|
// the last hold-release before firing `destroyFs`.
|
package/lib/mainFn/Daemon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Daemon.js","sourceRoot":"","sources":["../../../lib/mainFn/Daemon.ts"],"names":[],"mappings":";;;AACA,iEAA6D;AAC7D,2EAAuE;AACvE,kCAA8B;AAE9B,2DAAuD;AAIvD,MAAM,oBAAoB,GAAG,IAAI,CAAA;AACjC,MAAM,cAAc,GAAG,KAAK,CAAA;AAE5B
|
|
1
|
+
{"version":3,"file":"Daemon.js","sourceRoot":"","sources":["../../../lib/mainFn/Daemon.ts"],"names":[],"mappings":";;;AACA,iEAA6D;AAC7D,2EAAuE;AACvE,kCAA8B;AAE9B,2DAAuD;AAIvD,MAAM,oBAAoB,GAAG,IAAI,CAAA;AACjC,MAAM,cAAc,GAAG,KAAK,CAAA;AAE5B;;;;;;;;;;;;;GAaG;AACH,MAAa,MAGX,SAAQ,WAAI;IAOZ,YACW,YAAe,EAChB,YAA2D,EAC1D,UAAmB,KAAK;QAEjC,KAAK,EAAE,CAAA;QAJE,iBAAY,GAAZ,YAAY,CAAG;QAChB,iBAAY,GAAZ,YAAY,CAA+C;QAC1D,YAAO,GAAP,OAAO,CAAiB;QAT3B,sBAAiB,GAA0C,IAAI,CAAA;QAC7D,kBAAa,GAAG,KAAK,CAAA;QACvB,cAAS,GAAmC,EAAE,CAAA;QAC9C,SAAI,GAA2D,IAAI,CAAA;QACnE,4BAAuB,GAAiC,IAAI,CAAA;QAC5D,cAAS,GAAG,KAAK,CAAA;QAOvB,yEAAyE;QACzE,yEAAyE;QACzE,wEAAwE;QACxE,iDAAiD;QACjD,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAA;IAC7B,CAAC;IACD,8EAA8E;IAC9E,SAAS;QACP,OAAO,IAAI,CAA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AO;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,2BAAY,CAAC,CAAA;QAE9C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;QACtB,CAAC;QAED,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAA;YAC5C,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAA;YACnC,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,2BAAY,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,IAAI,CAAC,WAGV;QACC,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAE5B,mEAAmE;QACnE,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,2BAAY,EAAC,IAAA,iBAAO,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACxE,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAA8B;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACzB,CAAC;IACD,MAAM;QACJ,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,2BAAY,EAAC,IAAA,iBAAO,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClD,CAAC;CACF;AA9OD,wBA8OC"}
|
package/lib/mainFn/Daemons.d.ts
CHANGED
|
@@ -258,10 +258,23 @@ export declare class Daemons<Manifest extends T.SDKManifest, Ids extends string>
|
|
|
258
258
|
* re-runs that diff to "leave alone"; the reconciler throws at hash time
|
|
259
259
|
* if it sees one.
|
|
260
260
|
*
|
|
261
|
+
* Return the result from `setupMain` — it is a {@link T.DaemonBuildable},
|
|
262
|
+
* exactly like a static `Daemons.of(...)` chain:
|
|
263
|
+
*
|
|
264
|
+
* ```typescript
|
|
265
|
+
* export const main = sdk.setupMain(async ({ effects }) => {
|
|
266
|
+
* return sdk.Daemons.dynamic(effects, async ({ effects }) => {
|
|
267
|
+
* const sites = await storeJson.read((s) => s.sites).const(effects)
|
|
268
|
+
* return sdk.Daemons.of(effects).addDaemon(...)
|
|
269
|
+
* })
|
|
270
|
+
* })
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @param effects The effects context, from `setupMain`
|
|
261
274
|
* @param fn Async builder invoked on startup and on every `constRetry`. Must return a `Daemons` in record-mode (not pre-`build()`-ed)
|
|
262
|
-
* @returns A
|
|
275
|
+
* @returns A {@link DaemonsReconciler} — a `T.DaemonBuildable` to return from `setupMain`
|
|
263
276
|
*/
|
|
264
|
-
static dynamic<Manifest extends T.SDKManifest>(fn: DaemonsBuilder<Manifest>):
|
|
277
|
+
static dynamic<Manifest extends T.SDKManifest>(effects: T.Effects, fn: DaemonsBuilder<Manifest>): DaemonsReconciler<Manifest>;
|
|
265
278
|
private appendEntry;
|
|
266
279
|
/**
|
|
267
280
|
* Register a long-running daemon process.
|
package/lib/mainFn/Daemons.js
CHANGED
|
@@ -134,11 +134,24 @@ class Daemons {
|
|
|
134
134
|
* re-runs that diff to "leave alone"; the reconciler throws at hash time
|
|
135
135
|
* if it sees one.
|
|
136
136
|
*
|
|
137
|
+
* Return the result from `setupMain` — it is a {@link T.DaemonBuildable},
|
|
138
|
+
* exactly like a static `Daemons.of(...)` chain:
|
|
139
|
+
*
|
|
140
|
+
* ```typescript
|
|
141
|
+
* export const main = sdk.setupMain(async ({ effects }) => {
|
|
142
|
+
* return sdk.Daemons.dynamic(effects, async ({ effects }) => {
|
|
143
|
+
* const sites = await storeJson.read((s) => s.sites).const(effects)
|
|
144
|
+
* return sdk.Daemons.of(effects).addDaemon(...)
|
|
145
|
+
* })
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @param effects The effects context, from `setupMain`
|
|
137
150
|
* @param fn Async builder invoked on startup and on every `constRetry`. Must return a `Daemons` in record-mode (not pre-`build()`-ed)
|
|
138
|
-
* @returns A
|
|
151
|
+
* @returns A {@link DaemonsReconciler} — a `T.DaemonBuildable` to return from `setupMain`
|
|
139
152
|
*/
|
|
140
|
-
static dynamic(fn) {
|
|
141
|
-
return
|
|
153
|
+
static dynamic(effects, fn) {
|
|
154
|
+
return new DaemonsReconciler(effects, fn);
|
|
142
155
|
}
|
|
143
156
|
appendEntry(entry) {
|
|
144
157
|
return new Daemons(this.effects, [...this.ids, entry.id], [...this.entries, entry]);
|