@intentius/chant-lexicon-fly 0.90.0 → 0.93.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.
- package/README.md +27 -0
- package/dist/components/capability-plugin.d.ts +1 -0
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/fly-release.d.ts +195 -0
- package/dist/components/fly-release.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/fly-site.d.ts +86 -0
- package/dist/composites/fly-site.d.ts.map +1 -0
- package/dist/describe-resources.d.ts +11 -0
- package/dist/describe-resources.d.ts.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +4 -4
- package/dist/manifest.json +1 -1
- package/dist/op/activities/fly-apply.d.ts +8 -22
- package/dist/op/activities/fly-apply.d.ts.map +1 -1
- package/dist/op/activities/fly-release-step.d.ts +24 -0
- package/dist/op/activities/fly-release-step.d.ts.map +1 -0
- package/dist/op/activities/fly-rollback-step.d.ts +25 -0
- package/dist/op/activities/fly-rollback-step.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +8 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/machine-release.d.ts +192 -0
- package/dist/op/activities/machine-release.d.ts.map +1 -0
- package/dist/op/activities/machines-contract.d.ts +8 -0
- package/dist/op/activities/machines-contract.d.ts.map +1 -1
- package/dist/op/activities/machines-fake.d.ts +55 -0
- package/dist/op/activities/machines-fake.d.ts.map +1 -0
- package/dist/op/activities/machines-local-cli.d.ts +20 -0
- package/dist/op/activities/machines-local-cli.d.ts.map +1 -0
- package/dist/op/activities/machines-local.d.ts +107 -0
- package/dist/op/activities/machines-local.d.ts.map +1 -0
- package/dist/op/activities/sprite-fs.d.ts +12 -3
- package/dist/op/activities/sprite-fs.d.ts.map +1 -1
- package/dist/op/activities/sprite-service-converge.d.ts +107 -0
- package/dist/op/activities/sprite-service-converge.d.ts.map +1 -0
- package/dist/op/activities/sprites-fake.d.ts +18 -1
- package/dist/op/activities/sprites-fake.d.ts.map +1 -1
- package/dist/op/activities/sprites.d.ts +29 -9
- package/dist/op/activities/sprites.d.ts.map +1 -1
- package/dist/op/activity-contracts.d.ts +62 -0
- package/dist/op/activity-contracts.d.ts.map +1 -0
- package/dist/op/builders.d.ts +45 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/release-metadata.d.ts +48 -0
- package/dist/release-metadata.d.ts.map +1 -0
- package/dist/release-store.d.ts +36 -0
- package/dist/release-store.d.ts.map +1 -0
- package/dist/skills/chant-fly-ops.md +100 -0
- package/dist/skills/chant-fly-sprites.md +2 -1
- package/package.json +11 -4
- package/src/components/capability-plugin.ts +11 -3
- package/src/components/fly-release.test.ts +378 -0
- package/src/components/fly-release.ts +458 -0
- package/src/components/index.ts +16 -0
- package/src/composites/catalog.test.ts +2 -1
- package/src/composites/catalog.ts +98 -0
- package/src/composites/fly-site.test.ts +66 -0
- package/src/composites/fly-site.ts +140 -0
- package/src/describe-resources.test.ts +18 -3
- package/src/describe-resources.ts +69 -5
- package/src/index.ts +20 -0
- package/src/op/activities/fly-apply.ts +15 -3
- package/src/op/activities/fly-release-step.ts +32 -0
- package/src/op/activities/fly-rollback-step.ts +33 -0
- package/src/op/activities/index.ts +48 -0
- package/src/op/activities/machine-release.integration.test.ts +113 -0
- package/src/op/activities/machine-release.test.ts +138 -0
- package/src/op/activities/machine-release.ts +429 -0
- package/src/op/activities/machines-contract.docker.integration.test.ts +10 -1
- package/src/op/activities/machines-contract.test.ts +11 -1
- package/src/op/activities/machines-contract.ts +17 -0
- package/src/op/activities/machines-fake.ts +167 -0
- package/src/op/activities/machines-local-cli.ts +73 -0
- package/src/op/activities/machines-local.test.ts +225 -0
- package/src/op/activities/machines-local.ts +437 -0
- package/src/op/activities/sprite-exec-options.docker.integration.test.ts +70 -0
- package/src/op/activities/sprite-fs.test.ts +55 -0
- package/src/op/activities/sprite-fs.ts +14 -5
- package/src/op/activities/sprite-service-converge.test.ts +268 -0
- package/src/op/activities/sprite-service-converge.ts +268 -0
- package/src/op/activities/sprites-fake.ts +51 -8
- package/src/op/activities/sprites.integration.test.ts +30 -0
- package/src/op/activities/sprites.test.ts +20 -0
- package/src/op/activities/sprites.ts +50 -10
- package/src/op/activity-contracts.test.ts +71 -0
- package/src/op/activity-contracts.ts +67 -0
- package/src/op/builders.ts +57 -0
- package/src/release-metadata.ts +72 -0
- package/src/release-store.ts +70 -0
- package/src/skills/chant-fly-ops.md +100 -0
- package/src/skills/chant-fly-sprites.md +2 -1
|
@@ -7,12 +7,20 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { flyApply, toApplyResult, flyDelete, applyApp, applyMachine, destroyMachine, deleteApp, listMachines, pruneMachines, waitForMachine, acquireLease, releaseLease, withLease, resolveEndpoint, parsePlan, isAppRequest, isMachineRequest, machineAppSegment, resolveApp, appNameFromRequest, isChantOwned, configEqual, isLeaseConflict, defaultFlyHttp, DEFAULT_FLAPS_BASE_URL, LEASE_NONCE_HEADER, } from "./fly-apply.js";
|
|
9
9
|
export type { FlyApplyArgs, FlyPlan, FlapsRequest, FlapsMachine, FlyHttp, WaitOpts, ApplyCtx } from "./fly-apply.js";
|
|
10
|
+
export { flyMachineRelease, flyMachineExec, flyMachineRestart, flyMachineStop, flyMachineVerify, flyMachineRestore, } from "./machine-release.js";
|
|
11
|
+
export { flyRelease } from "./fly-release-step.js";
|
|
12
|
+
export type { FlyReleaseArgs, FlyReleaseResult } from "./fly-release-step.js";
|
|
13
|
+
export { flyRollback } from "./fly-rollback-step.js";
|
|
14
|
+
export type { FlyRollbackArgs, FlyRollbackResult } from "./fly-rollback-step.js";
|
|
15
|
+
export type { MachineRelease, FlyMachineReleaseArgs, FlyMachineReleaseResult, MachineFile, FlyMachineExecArgs, FlyMachineExecResult, FlyMachineStateArgs, FlyMachineVerifyArgs, FlyMachineRestoreArgs, } from "./machine-release.js";
|
|
10
16
|
export { flapsUp, flapsDown, flapsRunCommand, flapsRmCommand, flapsExistsCommand, flapsHealthUrl, flapsEndpoint, } from "./flaps.js";
|
|
11
17
|
export type { FlapsUpArgs, FlapsDownArgs } from "./flaps.js";
|
|
12
18
|
export { spriteCreate, spriteExec, spriteCheckpoint, spriteRestore, listCheckpoints, spriteDestroy, spriteDelete, spriteUrl, resolveSpritesEndpoint, resolveSpritesToken, defaultSpritesHttp, spriteCreateBody, parseCreateResponse, accumulateExecFrames, parseCheckpointNdjson, pickCheckpointByComment, splitCommand, spriteExecWsUrl, DEFAULT_SPRITES_BASE_URL, } from "./sprites.js";
|
|
13
19
|
export type { SpritesHttp, SpriteCreateArgs, SpriteCreateResult, SpriteExecArgs, SpriteExecResult, SpriteCheckpointArgs, SpriteCheckpointResult, SpriteRestoreArgs, ListCheckpointsArgs, Checkpoint, SpriteDestroyArgs, SpriteDeleteArgs, SpriteUrlArgs, SpriteUrlResult, } from "./sprites.js";
|
|
14
20
|
export { spriteServiceCreate, spriteServiceGet, spriteServiceList, spriteServiceStart, spriteServiceStop, spriteServiceDelete, spriteServiceLogs, spriteServiceCreateBody, parseServiceLogNdjson, } from "./sprite-services.js";
|
|
15
21
|
export type { SpriteService, SpriteServiceState, SpriteServiceCreateArgs, SpriteServiceGetArgs, SpriteServiceListArgs, SpriteServiceStartArgs, SpriteServiceStopArgs, SpriteServiceDeleteArgs, SpriteServiceLogsArgs, SpriteServiceLogsResult, } from "./sprite-services.js";
|
|
22
|
+
export { spriteServicesObserve, spriteServiceRestart, declaredServices, findSpriteEnv, parseServicesList, probeHealth, } from "./sprite-service-converge.js";
|
|
23
|
+
export type { DeclaredSpriteService, SpriteServicesObserveArgs, SpriteServicesObserveResult, SpriteServiceRestartArgs, SpriteServiceRestartResult, } from "./sprite-service-converge.js";
|
|
16
24
|
export { spriteWriteFile, spriteReadFile, spriteListDir, spriteRemove, spriteFsUrl, defaultSpritesRawHttp, } from "./sprite-fs.js";
|
|
17
25
|
export type { SpritesRawHttp, SpriteWriteFileArgs, SpriteReadFileArgs, SpriteReadFileResult, SpriteListDirArgs, SpriteDirEntry, SpriteRemoveArgs, } from "./sprite-fs.js";
|
|
18
26
|
export { spriteApplyNetworkPolicy, spriteApplyServices, validateNetworkRules, networkRulesEqual, validateServices, serviceConfigEqual, } from "./sprite-config.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EACT,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/op/activities/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EACT,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,k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cAAc,EACd,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The release a Fly Machine serves, and the Machines activities that put one
|
|
3
|
+
* there (#2736, ws-056).
|
|
4
|
+
*
|
|
5
|
+
* chud's `Chud::FlySite` ran a site as one App served by one Machine and kept
|
|
6
|
+
* the release in the Machine's metadata. That moves here: the App and the
|
|
7
|
+
* Machine are this lexicon's own resources, and a release is the declared
|
|
8
|
+
* Machine with {@link RELEASE_METADATA_KEYS} stamped into its
|
|
9
|
+
* `config.metadata`. Because the record is on the Machine itself, any checkout
|
|
10
|
+
* can read which release is serving (`describeResources` reports it, and
|
|
11
|
+
* `chant components status --live` compares it with the release ledger).
|
|
12
|
+
*
|
|
13
|
+
* The site steps are activities over the Machines API, each usable from an
|
|
14
|
+
* Op by name and composed by the `fly-release` and `fly-rollback` capabilities
|
|
15
|
+
* (../../components/fly-release.ts):
|
|
16
|
+
*
|
|
17
|
+
* - {@link flyMachineRelease}: upload and start. Apply the declared plan with
|
|
18
|
+
* the Machine serving the release (its image or env overridden when the
|
|
19
|
+
* release says so), and report the release and config it replaced.
|
|
20
|
+
* - {@link flyMachineExec}: run a command inside the Machine (a migration).
|
|
21
|
+
* - {@link flyMachineRestart}, {@link flyMachineStop}: under a lease, then
|
|
22
|
+
* wait for the Machine to settle.
|
|
23
|
+
* - {@link flyMachineVerify}: the Machine is started with this release in its
|
|
24
|
+
* metadata, and, given a URL, its health endpoint answers.
|
|
25
|
+
* - {@link flyMachineRestore}: put a recorded Machine config back (restore on
|
|
26
|
+
* a failed release, and rollback).
|
|
27
|
+
*
|
|
28
|
+
* Every activity takes the flaps endpoint and token the way `flyApply` does
|
|
29
|
+
* (`FLY_FLAPS_BASE_URL`, `FLY_API_TOKEN`), so the same code reaches mudflaps
|
|
30
|
+
* or a real Fly org, and an injectable `http` for tests (./machines-fake.ts).
|
|
31
|
+
*/
|
|
32
|
+
import { type ApplyCtx, type FlapsMachine, type FlapsRequest, type FlyHttp, type FlyPlan, type WaitOpts } from "./fly-apply.js";
|
|
33
|
+
import { type MachineConfig, type MachineRelease } from "../../release-metadata.js";
|
|
34
|
+
export { RELEASE_METADATA_KEYS, readMachineRelease, withReleaseMetadata } from "../../release-metadata.js";
|
|
35
|
+
export type { MachineRelease } from "../../release-metadata.js";
|
|
36
|
+
/** The App and Machine a release targets in a plan. */
|
|
37
|
+
export interface ReleaseTarget {
|
|
38
|
+
app: string;
|
|
39
|
+
/** The plan entity that declares the Machine. */
|
|
40
|
+
entity: string;
|
|
41
|
+
/** The Machine's name on Fly (its `name`, else the entity name). */
|
|
42
|
+
name: string;
|
|
43
|
+
request: FlapsRequest;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The Machine a release targets: the plan's one Machine, or the one `machine`
|
|
47
|
+
* names (an entity name or a Machine name). Pure.
|
|
48
|
+
*/
|
|
49
|
+
export declare function releaseTarget(plan: FlyPlan, machine?: string): ReleaseTarget;
|
|
50
|
+
/** The live Machine named `name` (or with id `name`) in `app`; undefined when there is none. */
|
|
51
|
+
export declare function findMachine(ctx: ApplyCtx, app: string, name: string, http: FlyHttp, signal?: AbortSignal): Promise<FlapsMachine | undefined>;
|
|
52
|
+
/** Where to reach flaps, as every activity here takes it. */
|
|
53
|
+
export interface FlapsTarget {
|
|
54
|
+
/** flaps endpoint override. Default: `FLY_FLAPS_BASE_URL`, else real Fly. */
|
|
55
|
+
endpoint?: string;
|
|
56
|
+
/** Bearer token for real Fly. Default: `FLY_API_TOKEN`. */
|
|
57
|
+
token?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface FlyMachineReleaseArgs extends FlapsTarget {
|
|
60
|
+
/** Path to the fly build output (`chant build --lexicon fly -o <path>`). */
|
|
61
|
+
planPath?: string;
|
|
62
|
+
/** The plan itself, in place of `planPath`. */
|
|
63
|
+
plan?: FlyPlan;
|
|
64
|
+
/** The Machine that serves the release, when the plan declares more than one. */
|
|
65
|
+
machine?: string;
|
|
66
|
+
/** The release to serve. `previousDigest` is filled in from the Machine it replaces. */
|
|
67
|
+
release: MachineRelease;
|
|
68
|
+
/** An image to run in place of the declared one (a digest-pinned image a publish step produced). */
|
|
69
|
+
image?: string;
|
|
70
|
+
/** Env to add to the declared Machine's env. */
|
|
71
|
+
env?: Record<string, string>;
|
|
72
|
+
/**
|
|
73
|
+
* Files the release puts on the Machine, added to the declared ones: a
|
|
74
|
+
* source release's tree (#2782). A declared file at the same path is
|
|
75
|
+
* replaced.
|
|
76
|
+
*/
|
|
77
|
+
files?: MachineFile[];
|
|
78
|
+
/** The command the Machine starts, in place of the image's: an argv, or a string run with `sh -c`. */
|
|
79
|
+
cmd?: string[] | string;
|
|
80
|
+
wait?: WaitOpts;
|
|
81
|
+
}
|
|
82
|
+
/** One file a Machine's config carries, as the Machines API takes it. */
|
|
83
|
+
export interface MachineFile {
|
|
84
|
+
guest_path: string;
|
|
85
|
+
/** The file's bytes, base64. */
|
|
86
|
+
raw_value: string;
|
|
87
|
+
/** Unix mode, such as 0o755 for an executable. */
|
|
88
|
+
mode?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface FlyMachineReleaseResult {
|
|
91
|
+
app: string;
|
|
92
|
+
machine: {
|
|
93
|
+
id: string;
|
|
94
|
+
name: string;
|
|
95
|
+
};
|
|
96
|
+
/** What the apply did to the Machine. */
|
|
97
|
+
action: "created" | "updated" | "noop";
|
|
98
|
+
/** The release the Machine serves now. */
|
|
99
|
+
release: MachineRelease;
|
|
100
|
+
/** The Machine config applied: what a later rollback to this release puts back. */
|
|
101
|
+
config: MachineConfig;
|
|
102
|
+
/** What the Machine served before, when it existed: its release (if it named one) and its config. */
|
|
103
|
+
previous: {
|
|
104
|
+
release?: MachineRelease;
|
|
105
|
+
config: MachineConfig;
|
|
106
|
+
} | null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Upload and start: apply the declared plan (the App, its Volumes, IPs,
|
|
110
|
+
* Secrets) with the Machine serving `release`. The Machine is updated in place
|
|
111
|
+
* under a lease, so the release serves from here on. A Machine that already
|
|
112
|
+
* serves this release keeps the `previousDigest` it shipped with, so running a
|
|
113
|
+
* release twice never makes it its own predecessor.
|
|
114
|
+
*/
|
|
115
|
+
export declare function flyMachineRelease(args: FlyMachineReleaseArgs, signal?: AbortSignal, http?: FlyHttp): Promise<FlyMachineReleaseResult>;
|
|
116
|
+
export interface FlyMachineExecArgs extends FlapsTarget {
|
|
117
|
+
app: string;
|
|
118
|
+
/** The Machine's name or id. */
|
|
119
|
+
machine: string;
|
|
120
|
+
/** The command: an argv, or a string run with `sh -c`. */
|
|
121
|
+
command: string[] | string;
|
|
122
|
+
/** Seconds the Machines API lets the command run. Default 120. */
|
|
123
|
+
timeoutSecs?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface FlyMachineExecResult {
|
|
126
|
+
exitCode: number;
|
|
127
|
+
stdout: string;
|
|
128
|
+
stderr: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Run a command inside the Machine (the Machines API's exec). A non-zero exit
|
|
132
|
+
* throws, with the command's output, so the step fails rather than going on
|
|
133
|
+
* over a half-migrated database.
|
|
134
|
+
*/
|
|
135
|
+
export declare function flyMachineExec(args: FlyMachineExecArgs, signal?: AbortSignal, http?: FlyHttp): Promise<FlyMachineExecResult>;
|
|
136
|
+
export interface FlyMachineStateArgs extends FlapsTarget {
|
|
137
|
+
app: string;
|
|
138
|
+
/** The Machine's name or id. */
|
|
139
|
+
machine: string;
|
|
140
|
+
wait?: WaitOpts;
|
|
141
|
+
}
|
|
142
|
+
/** Restart the Machine under a lease (the app starts again on migrated data), and wait for it to be started. */
|
|
143
|
+
export declare function flyMachineRestart(args: FlyMachineStateArgs, signal?: AbortSignal, http?: FlyHttp): Promise<{
|
|
144
|
+
id: string;
|
|
145
|
+
state: string;
|
|
146
|
+
}>;
|
|
147
|
+
/** Stop the Machine under a lease, and wait for it to be stopped. A Machine that is not started is left alone. */
|
|
148
|
+
export declare function flyMachineStop(args: FlyMachineStateArgs, signal?: AbortSignal, http?: FlyHttp): Promise<{
|
|
149
|
+
id: string;
|
|
150
|
+
state: string;
|
|
151
|
+
}>;
|
|
152
|
+
export interface FlyMachineVerifyArgs extends FlapsTarget {
|
|
153
|
+
app: string;
|
|
154
|
+
machine: string;
|
|
155
|
+
/** The release digest the Machine must name. */
|
|
156
|
+
digest: string;
|
|
157
|
+
/** The app's public URL; with it, its health endpoint must answer. */
|
|
158
|
+
url?: string;
|
|
159
|
+
/** Path of the health endpoint under `url`. Default `/health`. */
|
|
160
|
+
healthPath?: string;
|
|
161
|
+
/** How long to keep asking. Default 120s. */
|
|
162
|
+
timeoutMs?: number;
|
|
163
|
+
/** Delay between asks. Default 1s. */
|
|
164
|
+
intervalMs?: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The Machine is started and its metadata names release `digest`. Given a
|
|
168
|
+
* `url`, its health endpoint answers 2xx too, and when that answer is JSON
|
|
169
|
+
* naming a `revision` or `digest`, it is this release's (the commit or the
|
|
170
|
+
* digest). Retries until `timeoutMs`, then throws the last reason.
|
|
171
|
+
*/
|
|
172
|
+
export declare function flyMachineVerify(args: FlyMachineVerifyArgs, signal?: AbortSignal, http?: FlyHttp, fetchImpl?: typeof fetch): Promise<{
|
|
173
|
+
id: string;
|
|
174
|
+
release: MachineRelease;
|
|
175
|
+
}>;
|
|
176
|
+
export interface FlyMachineRestoreArgs extends FlapsTarget {
|
|
177
|
+
app: string;
|
|
178
|
+
machine: string;
|
|
179
|
+
/** The Machine config to put back, as a release applied it (its metadata names that release). */
|
|
180
|
+
config: MachineConfig;
|
|
181
|
+
wait?: WaitOpts;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Put a recorded Machine config back: update the Machine to exactly `config`
|
|
185
|
+
* under a lease and wait for it to be started. Used on a failed release (the
|
|
186
|
+
* config it replaced) and by a rollback (the config an earlier release applied).
|
|
187
|
+
*/
|
|
188
|
+
export declare function flyMachineRestore(args: FlyMachineRestoreArgs, signal?: AbortSignal, http?: FlyHttp): Promise<{
|
|
189
|
+
id: string;
|
|
190
|
+
release?: MachineRelease;
|
|
191
|
+
}>;
|
|
192
|
+
//# sourceMappingURL=machine-release.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine-release.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machine-release.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAaL,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAA2C,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE1H,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACxG,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,M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OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC,CAgBnD"}
|
|
@@ -33,4 +33,12 @@ export declare const MACHINES_CONTRACT: readonly MachinesEndpoint[];
|
|
|
33
33
|
export declare function normalizeEndpoint(method: string, path: string): string;
|
|
34
34
|
/** The contract as a set of normalized `METHOD path` keys. */
|
|
35
35
|
export declare function contractKeys(): Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* The flaps endpoints the release activities (./machine-release.ts, #2736)
|
|
38
|
+
* add beyond the applier's: getting one Machine back, exec (a migration),
|
|
39
|
+
* restart and stop. The applier's own contract above stays exec-free; these
|
|
40
|
+
* are the site steps', and the docker-gated coverage test holds the pinned
|
|
41
|
+
* mudflaps to them the same way.
|
|
42
|
+
*/
|
|
43
|
+
export declare const MACHINE_RELEASE_CONTRACT: readonly MachinesEndpoint[];
|
|
36
44
|
//# sourceMappingURL=machines-contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machines-contract.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machines-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,gBAAgB,EA8B/C,CAAC;AAEX,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,CAAC,CAE1C"}
|
|
1
|
+
{"version":3,"file":"machines-contract.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machines-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,gBAAgB,EA8B/C,CAAC;AAEX,4FAA4F;AAC5F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,CAAC,CAE1C;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,gBAAgB,EAQtD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory Fly Machines (flaps) API, as a {@link FlyHttp} (#2736).
|
|
3
|
+
*
|
|
4
|
+
* The twin of ./sprites-fake.ts for the Machines side: the endpoints the
|
|
5
|
+
* applier (./fly-apply.ts) and the release activities (./machine-release.ts)
|
|
6
|
+
* call, answered from memory with the response shapes flaps and mudflaps use.
|
|
7
|
+
* Unit tests inject it where the default client would reach the network; the
|
|
8
|
+
* docker-gated tests run the same activities against the pinned mudflaps.
|
|
9
|
+
* It runs nothing; ./machines-local.ts is the opt-in mode that runs each
|
|
10
|
+
* started Machine's files and command on this host (#2831).
|
|
11
|
+
*
|
|
12
|
+
* Not an activity: nothing in ./index.ts exports it, so `loadActivities`
|
|
13
|
+
* never binds it.
|
|
14
|
+
*/
|
|
15
|
+
import type { FlyHttp } from "./fly-apply.js";
|
|
16
|
+
/** One Machine the fake holds. */
|
|
17
|
+
export interface FakeMachine {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
state: string;
|
|
21
|
+
instance_id: string;
|
|
22
|
+
config: Record<string, unknown> & {
|
|
23
|
+
metadata?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/** What an `exec` answers: the Machines API's exec envelope. */
|
|
27
|
+
export interface FakeExecResult {
|
|
28
|
+
exit_code: number;
|
|
29
|
+
stdout?: string;
|
|
30
|
+
stderr?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface MachinesFake {
|
|
33
|
+
http: FlyHttp;
|
|
34
|
+
apps: Set<string>;
|
|
35
|
+
machines: Map<string, FakeMachine[]>;
|
|
36
|
+
/** Every exec, in order: the app, the machine id and the command. */
|
|
37
|
+
execs: Array<{
|
|
38
|
+
app: string;
|
|
39
|
+
id: string;
|
|
40
|
+
command: string[];
|
|
41
|
+
}>;
|
|
42
|
+
/** Every call, as `METHOD path` (no base, no query). */
|
|
43
|
+
calls: string[];
|
|
44
|
+
/** The live machine named `name` in `app`, if any. */
|
|
45
|
+
machine(app: string, name: string): FakeMachine | undefined;
|
|
46
|
+
}
|
|
47
|
+
export interface MachinesFakeOptions {
|
|
48
|
+
/** Answer an exec. Default: exit 0 with no output. The running mode (./machines-local.ts) answers it by running the command. */
|
|
49
|
+
exec?: (app: string, machine: FakeMachine, command: string[]) => FakeExecResult | Promise<FakeExecResult>;
|
|
50
|
+
/** The state a created or updated machine settles in. Default `started`. */
|
|
51
|
+
settle?: (machine: FakeMachine) => string;
|
|
52
|
+
}
|
|
53
|
+
/** A fresh in-memory flaps. */
|
|
54
|
+
export declare function createMachinesFake(options?: MachinesFakeOptions): MachinesFake;
|
|
55
|
+
//# sourceMappingURL=machines-fake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machines-fake.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machines-fake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;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AE,CAAC,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC;CAC3C;AAOD,+BAA+B;AAC/B,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA4GlF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local Fly Machines API that runs its Machines (#2831), as a command:
|
|
3
|
+
*
|
|
4
|
+
* tsx node_modules/@intentius/chant-lexicon-fly/src/op/activities/machines-local-cli.ts \
|
|
5
|
+
* [--listen 4280] [--root <dir>] [--publish <port> | --publish <name>=<port> ...] [--log <file>]
|
|
6
|
+
*
|
|
7
|
+
* Point the release activities at it with `FLY_FLAPS_BASE_URL=http://127.0.0.1:4280`.
|
|
8
|
+
* `--publish 8080` publishes every Machine's service on 8080; `--publish web=8080`
|
|
9
|
+
* publishes the Machine named `web` there; with no `--publish` each Machine gets a free
|
|
10
|
+
* port, which the event lines say. SIGINT or SIGTERM stops every Machine's process
|
|
11
|
+
* and exits. See ./machines-local.ts.
|
|
12
|
+
*/
|
|
13
|
+
import { type LocalPublish } from "./machines-local.js";
|
|
14
|
+
export declare function parseArgs(argv: string[]): {
|
|
15
|
+
port: number;
|
|
16
|
+
root?: string;
|
|
17
|
+
publish?: LocalPublish;
|
|
18
|
+
log?: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=machines-local-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machines-local-cli.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machines-local-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,YAAY,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAyB/G"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local Fly Machines API that runs its Machines (#2831).
|
|
3
|
+
*
|
|
4
|
+
* ./machines-fake.ts answers the flaps endpoints from memory and runs nothing,
|
|
5
|
+
* and so does mudflaps. That is what unit tests want, and it stays the
|
|
6
|
+
* default. This module is the opt-in running mode: the same in-memory API,
|
|
7
|
+
* with each started Machine run as a process on this host, so a release that
|
|
8
|
+
* puts a source tree on a Machine (`config.files` plus `init.cmd`) can be
|
|
9
|
+
* checked over HTTP.
|
|
10
|
+
*
|
|
11
|
+
* For each Machine the fake holds in state `started`:
|
|
12
|
+
*
|
|
13
|
+
* - `config.files` are written at their `guest_path` (under `root` when one
|
|
14
|
+
* is given), and the files an earlier instance wrote are removed first, as
|
|
15
|
+
* a Machine's root filesystem starts again from its image;
|
|
16
|
+
* - `config.mounts` are directories that outlive instances (a Volume);
|
|
17
|
+
* - `init.exec`, or `init.entrypoint` then `init.cmd`, runs with
|
|
18
|
+
* `config.env`, and an `exec` (a migration) runs its command with the same
|
|
19
|
+
* env;
|
|
20
|
+
* - a service's `internal_port` is published on a host port: when the
|
|
21
|
+
* Machine's env sets `PORT` to an `internal_port`, the process gets the
|
|
22
|
+
* host port instead, since every Machine here shares the host's network.
|
|
23
|
+
*
|
|
24
|
+
* No image is pulled: the command runs on this host's binaries (a Node app
|
|
25
|
+
* runs on this host's Node).
|
|
26
|
+
*
|
|
27
|
+
* A create or an update (a new `instance_id`) starts the process again, a
|
|
28
|
+
* `restart` restarts it, a `stop` or a delete stops it, and a process that
|
|
29
|
+
* exits on its own leaves its Machine `stopped`. Each call answers only after
|
|
30
|
+
* that is done, and a started process is given until its published port
|
|
31
|
+
* accepts a connection, so the next call (a migration's exec, a health check)
|
|
32
|
+
* finds the files and the server.
|
|
33
|
+
*
|
|
34
|
+
* Processes run in their own process group. `close()` stops them all
|
|
35
|
+
* (SIGTERM, then SIGKILL); if the host process exits or is ended by SIGINT,
|
|
36
|
+
* SIGTERM or SIGHUP first, they are killed with it. Only a SIGKILL of the host
|
|
37
|
+
* process can leave them running.
|
|
38
|
+
*/
|
|
39
|
+
import { type FakeMachine, type MachinesFake, type MachinesFakeOptions } from "./machines-fake.js";
|
|
40
|
+
/** Where a Machine's service is published: one port for every Machine, a port per Machine name (or `app/name`), or a function. */
|
|
41
|
+
export type LocalPublish = number | Record<string, number> | ((app: string, machine: FakeMachine) => number | undefined);
|
|
42
|
+
export interface LocalMachinesOptions {
|
|
43
|
+
/**
|
|
44
|
+
* A host directory the Machines' guest paths are placed under: `/srv/app`
|
|
45
|
+
* becomes `<root>/srv/app`, in the files written, the mounts, and the
|
|
46
|
+
* command, exec and env strings that name those paths. Default: none, so a
|
|
47
|
+
* guest path is the same path on this host (a container or a box made for it).
|
|
48
|
+
*/
|
|
49
|
+
root?: string;
|
|
50
|
+
/** The host port a Machine's service is published on. Default: a free port per Machine, kept for its name. */
|
|
51
|
+
publish?: LocalPublish;
|
|
52
|
+
/** A file the processes' stdout and stderr are appended to. Default: this process's stderr. */
|
|
53
|
+
log?: string;
|
|
54
|
+
/** How long a started process is given to accept a connection on its published port. Default 15s. */
|
|
55
|
+
readyTimeoutMs?: number;
|
|
56
|
+
/** How long a stopped process is given after SIGTERM before SIGKILL. Default 5s. */
|
|
57
|
+
stopTimeoutMs?: number;
|
|
58
|
+
/** What happens, one line at a time (starts, stops, execs). Default: nothing is said. */
|
|
59
|
+
onEvent?: (line: string) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Kill the processes when this process gets SIGINT, SIGTERM or SIGHUP, then raise the signal again if nothing
|
|
62
|
+
* else handles it. Default true; a caller that handles those signals itself (and calls `close()`) passes false.
|
|
63
|
+
*/
|
|
64
|
+
handleSignals?: boolean;
|
|
65
|
+
/** Passed to the fake: the state a created or updated Machine settles in. */
|
|
66
|
+
settle?: MachinesFakeOptions["settle"];
|
|
67
|
+
}
|
|
68
|
+
/** A Machine's process, as {@link LocalMachines.processes} reports it. */
|
|
69
|
+
export interface LocalProcess {
|
|
70
|
+
app: string;
|
|
71
|
+
id: string;
|
|
72
|
+
name: string;
|
|
73
|
+
instance: string;
|
|
74
|
+
pid: number | undefined;
|
|
75
|
+
/** The host port its service is published on, when its env names one. */
|
|
76
|
+
port: number | undefined;
|
|
77
|
+
}
|
|
78
|
+
export interface LocalMachines extends MachinesFake {
|
|
79
|
+
/** `http://127.0.0.1:<port>` for the running Machine `name` in `app`, when its service is published. */
|
|
80
|
+
endpoint(app: string, name: string): string | undefined;
|
|
81
|
+
/** The processes running now. */
|
|
82
|
+
processes(): LocalProcess[];
|
|
83
|
+
/** Stop every process and remove its files. Mounts are kept. */
|
|
84
|
+
close(): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
/** An in-memory Machines API that runs each started Machine on this host. See the module header. */
|
|
87
|
+
export declare function createLocalMachines(options?: LocalMachinesOptions): LocalMachines;
|
|
88
|
+
export interface ServeLocalMachinesOptions extends LocalMachinesOptions {
|
|
89
|
+
/** The port the Machines API listens on. Default 4280, mudflaps' port; 0 picks a free one. */
|
|
90
|
+
port?: number;
|
|
91
|
+
/** Default 127.0.0.1. */
|
|
92
|
+
host?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ServedLocalMachines {
|
|
95
|
+
/** The flaps base URL, for `FLY_FLAPS_BASE_URL` or an `endpoint` argument. */
|
|
96
|
+
url: string;
|
|
97
|
+
machines: LocalMachines;
|
|
98
|
+
/** Stop every Machine's process, then the server. */
|
|
99
|
+
close(): Promise<void>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Serve {@link createLocalMachines} over HTTP, where the release activities
|
|
103
|
+
* reach it through `FLY_FLAPS_BASE_URL`. `GET /_mudflaps/health` answers 200,
|
|
104
|
+
* as mudflaps' health check does.
|
|
105
|
+
*/
|
|
106
|
+
export declare function serveLocalMachines(options?: ServeLocalMachinesOptions): Promise<ServedLocalMachines>;
|
|
107
|
+
//# sourceMappingURL=machines-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machines-local.d.ts","sourceRoot":"","sources":["../../../src/op/activities/machines-local.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAQH,OAAO,EAA2C,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEzI,kIAAkI;AAClI,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AAEzH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8GAA8G;IAC9G,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,+FAA+F;IAC/F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qGAAqG;IACrG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;CACxC;AAED,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,yEAAyE;IACzE,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,wGAAwG;IACxG,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACxD,iCAAiC;IACjC,SAAS,IAAI,YAAY,EAAE,CAAC;IAC5B,gEAAgE;IAChE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAwDD,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAqOrF;AAED,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,8FAA8F;IAC9F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,aAAa,CAAC;IACxB,qDAAqD;IACrD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiC9G"}
|
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
* read/write move raw file bytes in the body (not JSON), so these use a small
|
|
9
9
|
* raw HTTP client (`SpritesRawHttp`) rather than the JSON `SpritesHttp` the
|
|
10
10
|
* lifecycle activities use; path/mode/mkdir/recursive ride as query params.
|
|
11
|
-
* Endpoint + bearer resolution
|
|
12
|
-
* `
|
|
11
|
+
* Endpoint + bearer resolution go through `sprites.ts`'s shared resolvers
|
|
12
|
+
* (`resolveSpritesEndpoint`/`resolveSpritesToken`) — an explicit `endpoint` /
|
|
13
|
+
* `token` wins, then `SPRITES_BASE_URL`/`SPRITES_API_URL`, then
|
|
14
|
+
* `SPRITES_API_TOKEN`/its `SPRITE_TOKEN` alias (#2711, #2765: this module
|
|
15
|
+
* used to read `SPRITES_API_TOKEN` directly, missing the alias the other
|
|
16
|
+
* Sprites activities honor).
|
|
13
17
|
*/
|
|
14
18
|
/**
|
|
15
19
|
* Build a `/v1/sprites/{id}/fs/{op}?...` URL. `params` values that are undefined
|
|
@@ -29,7 +33,12 @@ export type SpritesRawHttp = (method: string, url: string, body?: string, header
|
|
|
29
33
|
* Default `fetch`-based raw client. Sends the body as-is with an
|
|
30
34
|
* `application/octet-stream` content-type and `Authorization: Bearer <token>`
|
|
31
35
|
* when a token is set (real Sprites); the fake ignores the token. The token
|
|
32
|
-
*
|
|
36
|
+
* resolves through `resolveSpritesToken` at call time — `SPRITES_API_TOKEN`,
|
|
37
|
+
* then its `SPRITE_TOKEN` alias (#2711, #2765) — the same resolver
|
|
38
|
+
* `sprites.ts`'s `defaultSpritesHttp` uses, so every fs activity
|
|
39
|
+
* (`spriteWriteFile`, `spriteReadFile`, `spriteListDir`, `spriteRemove`)
|
|
40
|
+
* authenticates the same way the lifecycle activities do. `fetchImpl` is
|
|
41
|
+
* injectable.
|
|
33
42
|
*/
|
|
34
43
|
export declare function defaultSpritesRawHttp(token?: string, fetchImpl?: typeof fetch): SpritesRawHttp;
|
|
35
44
|
export interface SpriteWriteFileArgs {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprite-fs.d.ts","sourceRoot":"","sources":["../../../src/op/activities/sprite-fs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"sprite-fs.d.ts","sourceRoot":"","sources":["../../../src/op/activities/sprite-fs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAcH;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,EACxC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,G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107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sprite's services as resources a `ConvergeOp` observes and converges
|
|
3
|
+
* (#2778).
|
|
4
|
+
*
|
|
5
|
+
* A box runs its app, hud, door and site as services a supervisor keeps
|
|
6
|
+
* running: sprite-env on a sprite, and a stand-in with the same command line
|
|
7
|
+
* elsewhere. No lexicon declares them, so a ConvergeOp can't observe them
|
|
8
|
+
* through an environment. It can through an observer step:
|
|
9
|
+
*
|
|
10
|
+
* - `spriteServicesObserve` reads the supervisor's list and probes each
|
|
11
|
+
* declared service's health URL, and returns one verdict per service,
|
|
12
|
+
* `in-sync`, `drifted` or `unknown`: the `ResourceObservation` a
|
|
13
|
+
* `ConvergeOp({ observe })` evaluates its rules against, once per service.
|
|
14
|
+
* - `spriteServiceRestart` restarts one service through the supervisor and
|
|
15
|
+
* waits for its health URL. It is the step of the Op a rule dispatches; the
|
|
16
|
+
* service is the one the rule fired for, which the dispatched run reads
|
|
17
|
+
* from `CHANT_CONVERGE_RESOURCE`.
|
|
18
|
+
*
|
|
19
|
+
* Both work in one of two ways. With no sprite `id`, they run inside the
|
|
20
|
+
* sprite and call `sprite-env services` (found on PATH or in /.sprite/bin,
|
|
21
|
+
* or at `spriteEnv`). With an `id`, they go through the Sprites API
|
|
22
|
+
* (`spriteServiceList`, `spriteServiceStop` and `spriteServiceStart`).
|
|
23
|
+
*/
|
|
24
|
+
import type { SpritesHttp } from "./sprites.js";
|
|
25
|
+
/** One service a box declares. */
|
|
26
|
+
export interface DeclaredSpriteService {
|
|
27
|
+
name: string;
|
|
28
|
+
/** A URL that answers 200 while the service works. Without one, the supervisor's state decides. */
|
|
29
|
+
health?: string;
|
|
30
|
+
/** Not defined yet is not drift: the service is left out until it exists (a site before its first release). */
|
|
31
|
+
optional?: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface Via {
|
|
34
|
+
/** The sprite, for the Sprites API. Without it, `sprite-env` inside the sprite. */
|
|
35
|
+
id?: string;
|
|
36
|
+
/** The `sprite-env` binary. Default: the one on PATH, else /.sprite/bin/sprite-env. */
|
|
37
|
+
spriteEnv?: string;
|
|
38
|
+
endpoint?: string;
|
|
39
|
+
token?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface SpriteServicesObserveArgs extends Via {
|
|
42
|
+
/** The declared services. */
|
|
43
|
+
services?: DeclaredSpriteService[];
|
|
44
|
+
/** A JSON file of `{ services: [...] }`, relative to the working directory, read on each tick. */
|
|
45
|
+
servicesFile?: string;
|
|
46
|
+
/** Health probes before a service counts as drifted. Default 3. */
|
|
47
|
+
probes?: number;
|
|
48
|
+
/** Time between probes, ms. Default 1000. */
|
|
49
|
+
probeIntervalMs?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface SpriteServicesObserveResult {
|
|
52
|
+
resources: {
|
|
53
|
+
name: string;
|
|
54
|
+
status: "in-sync" | "drifted" | "unknown";
|
|
55
|
+
detail: string;
|
|
56
|
+
}[];
|
|
57
|
+
/** Optional services that aren't defined yet. */
|
|
58
|
+
skipped: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface SpriteServiceRestartArgs extends Via {
|
|
61
|
+
/** The service. Default: the resource a ConvergeOp dispatched this run for (`CHANT_CONVERGE_RESOURCE`). */
|
|
62
|
+
name?: string;
|
|
63
|
+
/** Its health URL. Default: the one `services` or `servicesFile` declares for it. */
|
|
64
|
+
health?: string;
|
|
65
|
+
services?: DeclaredSpriteService[];
|
|
66
|
+
servicesFile?: string;
|
|
67
|
+
/** How long to wait for the health URL after the restart, ms. Default 60000. */
|
|
68
|
+
waitMs?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface SpriteServiceRestartResult {
|
|
71
|
+
name: string;
|
|
72
|
+
/** Whether its health URL answered, or null when it declares none. */
|
|
73
|
+
healthy: boolean | null;
|
|
74
|
+
}
|
|
75
|
+
/** The services declared inline and in `servicesFile`, inline first. */
|
|
76
|
+
export declare function declaredServices(args: {
|
|
77
|
+
services?: DeclaredSpriteService[];
|
|
78
|
+
servicesFile?: string;
|
|
79
|
+
}, cwd?: string): DeclaredSpriteService[];
|
|
80
|
+
/** The sprite-env binary, or null when there is none. */
|
|
81
|
+
export declare function findSpriteEnv(explicit?: string, env?: NodeJS.ProcessEnv): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* `sprite-env services list` as name to state. A sprite's sprite-env prints
|
|
84
|
+
* JSON (an array of services with `state.status`); a stand-in may print a
|
|
85
|
+
* tab-separated table whose second column is the state. Pure.
|
|
86
|
+
*/
|
|
87
|
+
export declare function parseServicesList(text: string): Map<string, string | null>;
|
|
88
|
+
/** One GET of a health URL: true on 200. */
|
|
89
|
+
export declare function probeHealth(url: string, signal?: AbortSignal): Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* Observe the declared services: one verdict each, for a ConvergeOp's rules.
|
|
92
|
+
* A service the supervisor doesn't have, or has stopped, is drifted; one
|
|
93
|
+
* with a health URL is in sync when the URL answers 200 within `probes`
|
|
94
|
+
* tries and drifted when it doesn't; one without is in sync while it runs.
|
|
95
|
+
* When the supervisor can't be read, every service is unknown, and unknown
|
|
96
|
+
* never remediates.
|
|
97
|
+
*/
|
|
98
|
+
export declare function spriteServicesObserve(args: SpriteServicesObserveArgs, signal?: AbortSignal, http?: SpritesHttp): Promise<SpriteServicesObserveResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Restart one service through its supervisor and wait for its health URL.
|
|
101
|
+
* The service is `name`, or the resource the ConvergeOp's rule fired for.
|
|
102
|
+
* Throws when neither names one, when the supervisor refuses, or when the
|
|
103
|
+
* service does not answer its health URL within `waitMs`.
|
|
104
|
+
*/
|
|
105
|
+
export declare function spriteServiceRestart(args: SpriteServiceRestartArgs, signal?: AbortSignal, http?: SpritesHttp): Promise<SpriteServiceRestartResult>;
|
|
106
|
+
export {};
|
|
107
|
+
//# sourceMappingURL=sprite-service-converge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sprite-service-converge.d.ts","sourceRoot":"","sources":["../../../src/op/activities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