@start9labs/start-sdk 0.4.0-beta.3 → 0.4.0-beta.31
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/base/lib/Effects.d.ts +8 -34
- package/base/lib/actions/index.d.ts +13 -14
- package/base/lib/actions/index.js +4 -4
- package/base/lib/actions/index.js.map +1 -1
- package/base/lib/actions/input/builder/inputSpec.d.ts +15 -26
- package/base/lib/actions/input/builder/inputSpec.js +10 -27
- package/base/lib/actions/input/builder/inputSpec.js.map +1 -1
- package/base/lib/actions/input/builder/list.d.ts +12 -24
- package/base/lib/actions/input/builder/list.js +19 -33
- package/base/lib/actions/input/builder/list.js.map +1 -1
- package/base/lib/actions/input/builder/value.d.ts +331 -70
- package/base/lib/actions/input/builder/value.js +505 -188
- package/base/lib/actions/input/builder/value.js.map +1 -1
- package/base/lib/actions/input/builder/variants.d.ts +11 -23
- package/base/lib/actions/input/builder/variants.js +16 -26
- package/base/lib/actions/input/builder/variants.js.map +1 -1
- package/base/lib/actions/input/inputSpecConstants.d.ts +6 -6
- package/base/lib/actions/input/inputSpecConstants.js +29 -26
- package/base/lib/actions/input/inputSpecConstants.js.map +1 -1
- package/base/lib/actions/setupActions.d.ts +19 -15
- package/base/lib/actions/setupActions.js +37 -14
- package/base/lib/actions/setupActions.js.map +1 -1
- package/base/lib/dependencies/dependencies.d.ts +2 -2
- package/base/lib/dependencies/dependencies.js +23 -15
- package/base/lib/dependencies/dependencies.js.map +1 -1
- package/base/lib/dependencies/setupDependencies.d.ts +1 -3
- package/base/lib/dependencies/setupDependencies.js +3 -12
- package/base/lib/dependencies/setupDependencies.js.map +1 -1
- package/base/lib/index.d.ts +1 -0
- package/base/lib/index.js +2 -1
- package/base/lib/index.js.map +1 -1
- package/base/lib/inits/index.d.ts +2 -0
- package/base/lib/inits/index.js +19 -0
- package/base/lib/inits/index.js.map +1 -0
- package/base/lib/inits/setupInit.d.ts +9 -0
- package/base/lib/inits/setupInit.js +40 -0
- package/base/lib/inits/setupInit.js.map +1 -0
- package/base/lib/inits/setupUninit.d.ts +25 -0
- package/base/lib/inits/setupUninit.js +24 -0
- package/base/lib/inits/setupUninit.js.map +1 -0
- package/base/lib/interfaces/Host.js +18 -6
- package/base/lib/interfaces/Host.js.map +1 -1
- package/base/lib/interfaces/Origin.d.ts +2 -2
- package/base/lib/interfaces/Origin.js +3 -3
- package/base/lib/interfaces/Origin.js.map +1 -1
- package/base/lib/interfaces/ServiceInterfaceBuilder.d.ts +2 -2
- package/base/lib/interfaces/setupInterfaces.d.ts +2 -4
- package/base/lib/interfaces/setupInterfaces.js +8 -19
- package/base/lib/interfaces/setupInterfaces.js.map +1 -1
- package/base/lib/osBindings/AddCategoryParams.d.ts +0 -2
- package/base/lib/osBindings/AddPackageToCategoryParams.d.ts +5 -0
- package/base/lib/osBindings/AddPackageToCategoryParams.js +3 -0
- package/base/lib/osBindings/AddPackageToCategoryParams.js.map +1 -0
- package/base/lib/osBindings/AttachParams.d.ts +1 -0
- package/base/lib/osBindings/Category.d.ts +0 -2
- package/base/lib/osBindings/Category.js +1 -0
- package/base/lib/osBindings/Category.js.map +1 -1
- package/base/lib/osBindings/CheckDependenciesResult.d.ts +3 -3
- package/base/lib/osBindings/ClearTasksParams.d.ts +5 -0
- package/base/lib/osBindings/{UnsetPublicParams.js → ClearTasksParams.js} +1 -1
- package/base/lib/osBindings/ClearTasksParams.js.map +1 -0
- package/base/lib/osBindings/CreateTaskParams.d.ts +15 -0
- package/base/lib/osBindings/CreateTaskParams.js +3 -0
- package/base/lib/osBindings/CreateTaskParams.js.map +1 -0
- package/base/lib/osBindings/FileType.d.ts +1 -0
- package/base/lib/osBindings/{NetworkInterfaceSetPublicParams.js → FileType.js} +1 -1
- package/base/lib/osBindings/FileType.js.map +1 -0
- package/base/lib/osBindings/GetOsVersionParams.d.ts +3 -3
- package/base/lib/osBindings/GetPackageParams.d.ts +1 -1
- package/base/lib/osBindings/MainStatus.d.ts +0 -2
- package/base/lib/osBindings/Manifest.d.ts +1 -0
- package/base/lib/osBindings/MountTarget.d.ts +2 -0
- package/base/lib/osBindings/PackageDataEntry.d.ts +4 -5
- package/base/lib/osBindings/Progress.d.ts +2 -0
- package/base/lib/osBindings/Progress.js +0 -1
- package/base/lib/osBindings/Progress.js.map +1 -1
- package/base/lib/osBindings/ProgressUnits.d.ts +1 -0
- package/base/lib/osBindings/ProgressUnits.js +4 -0
- package/base/lib/osBindings/ProgressUnits.js.map +1 -0
- package/base/lib/osBindings/Proxies.d.ts +4 -0
- package/base/lib/osBindings/Proxies.js +3 -0
- package/base/lib/osBindings/Proxies.js.map +1 -0
- package/base/lib/osBindings/ProxyInfo.d.ts +4 -0
- package/base/lib/osBindings/ProxyInfo.js +4 -0
- package/base/lib/osBindings/ProxyInfo.js.map +1 -0
- package/base/lib/osBindings/RemoveAdminParams.d.ts +4 -0
- package/base/lib/osBindings/RemoveAdminParams.js +3 -0
- package/base/lib/osBindings/RemoveAdminParams.js.map +1 -0
- package/base/lib/osBindings/RemoveAssetParams.d.ts +4 -0
- package/base/lib/osBindings/RemoveAssetParams.js +4 -0
- package/base/lib/osBindings/RemoveAssetParams.js.map +1 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.d.ts +5 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.js +3 -0
- package/base/lib/osBindings/RemovePackageFromCategoryParams.js.map +1 -0
- package/base/lib/osBindings/RemovePackageParams.d.ts +6 -0
- package/base/lib/osBindings/RemovePackageParams.js +3 -0
- package/base/lib/osBindings/RemovePackageParams.js.map +1 -0
- package/base/lib/osBindings/ServerInfo.d.ts +1 -0
- package/base/lib/osBindings/SetupExecuteParams.d.ts +1 -0
- package/base/lib/osBindings/Task.d.ts +13 -0
- package/base/lib/osBindings/Task.js +3 -0
- package/base/lib/osBindings/Task.js.map +1 -0
- package/base/lib/osBindings/TaskCondition.d.ts +1 -0
- package/base/lib/osBindings/TaskCondition.js +4 -0
- package/base/lib/osBindings/TaskCondition.js.map +1 -0
- package/base/lib/osBindings/TaskEntry.d.ts +5 -0
- package/base/lib/osBindings/TaskEntry.js +3 -0
- package/base/lib/osBindings/TaskEntry.js.map +1 -0
- package/base/lib/osBindings/TaskInput.d.ts +4 -0
- package/base/lib/osBindings/TaskInput.js +4 -0
- package/base/lib/osBindings/TaskInput.js.map +1 -0
- package/base/lib/osBindings/TaskSeverity.d.ts +1 -0
- package/base/lib/osBindings/TaskSeverity.js +4 -0
- package/base/lib/osBindings/TaskSeverity.js.map +1 -0
- package/base/lib/osBindings/TaskTrigger.d.ts +5 -0
- package/base/lib/osBindings/TaskTrigger.js +3 -0
- package/base/lib/osBindings/TaskTrigger.js.map +1 -0
- package/base/lib/osBindings/index.d.ts +15 -11
- package/base/lib/s9pk/index.js +5 -7
- package/base/lib/s9pk/index.js.map +1 -1
- package/base/lib/types.d.ts +22 -33
- package/base/lib/types.js +13 -0
- package/base/lib/types.js.map +1 -1
- package/base/lib/util/GetSystemSmtp.d.ts +4 -0
- package/base/lib/util/GetSystemSmtp.js +32 -2
- package/base/lib/util/GetSystemSmtp.js.map +1 -1
- package/base/lib/util/getServiceInterface.d.ts +14 -0
- package/base/lib/util/getServiceInterface.js +70 -1
- package/base/lib/util/getServiceInterface.js.map +1 -1
- package/base/lib/util/getServiceInterfaces.d.ts +4 -0
- package/base/lib/util/getServiceInterfaces.js +34 -1
- package/base/lib/util/getServiceInterfaces.js.map +1 -1
- package/base/lib/util/index.d.ts +0 -1
- package/base/lib/util/index.js +1 -3
- package/base/lib/util/index.js.map +1 -1
- package/package/lib/StartSdk.d.ts +108 -570
- package/package/lib/StartSdk.js +112 -428
- package/package/lib/StartSdk.js.map +1 -1
- package/package/lib/backup/Backups.d.ts +15 -3
- package/package/lib/backup/Backups.js +44 -28
- package/package/lib/backup/Backups.js.map +1 -1
- package/package/lib/backup/setupBackups.d.ts +5 -2
- package/package/lib/backup/setupBackups.js +7 -5
- package/package/lib/backup/setupBackups.js.map +1 -1
- package/package/lib/health/HealthCheck.d.ts +0 -1
- package/package/lib/health/HealthCheck.js +1 -7
- package/package/lib/health/HealthCheck.js.map +1 -1
- package/package/lib/health/checkFns/runHealthScript.d.ts +2 -1
- package/package/lib/health/checkFns/runHealthScript.js +1 -1
- package/package/lib/health/checkFns/runHealthScript.js.map +1 -1
- package/package/lib/index.d.ts +0 -3
- package/package/lib/index.js +1 -8
- package/package/lib/index.js.map +1 -1
- package/package/lib/inits/index.d.ts +2 -3
- package/package/lib/inits/index.js +16 -3
- package/package/lib/inits/index.js.map +1 -1
- package/package/lib/inits/setupInit.d.ts +7 -13
- package/package/lib/inits/setupInit.js +22 -48
- package/package/lib/inits/setupInit.js.map +1 -1
- package/package/lib/inits/setupInstall.d.ts +10 -10
- package/package/lib/inits/setupInstall.js.map +1 -1
- package/package/lib/inits/setupUninit.d.ts +7 -0
- package/package/lib/inits/setupUninit.js +14 -0
- package/package/lib/inits/setupUninit.js.map +1 -0
- package/package/lib/inits/setupUninstall.d.ts +5 -5
- package/package/lib/inits/setupUninstall.js.map +1 -1
- package/package/lib/mainFn/CommandController.d.ts +6 -24
- package/package/lib/mainFn/CommandController.js +72 -48
- package/package/lib/mainFn/CommandController.js.map +1 -1
- package/package/lib/mainFn/Daemon.d.ts +15 -22
- package/package/lib/mainFn/Daemon.js +56 -13
- package/package/lib/mainFn/Daemon.js.map +1 -1
- package/package/lib/mainFn/Daemons.d.ts +72 -49
- package/package/lib/mainFn/Daemons.js +87 -23
- package/package/lib/mainFn/Daemons.js.map +1 -1
- package/package/lib/mainFn/HealthDaemon.d.ts +8 -7
- package/package/lib/mainFn/HealthDaemon.js +79 -38
- package/package/lib/mainFn/HealthDaemon.js.map +1 -1
- package/package/lib/mainFn/Mounts.d.ts +38 -43
- package/package/lib/mainFn/Mounts.js +19 -48
- package/package/lib/mainFn/Mounts.js.map +1 -1
- package/package/lib/mainFn/Oneshot.d.ts +12 -0
- package/package/lib/mainFn/Oneshot.js +23 -0
- package/package/lib/mainFn/Oneshot.js.map +1 -0
- package/package/lib/mainFn/index.d.ts +1 -1
- package/package/lib/manifest/setupManifest.js +2 -0
- package/package/lib/manifest/setupManifest.js.map +1 -1
- package/package/lib/store/getStore.js +7 -2
- package/package/lib/store/getStore.js.map +1 -1
- package/package/lib/test/host.test.js +1 -1
- package/package/lib/test/host.test.js.map +1 -1
- package/package/lib/test/inputSpecBuilder.test.js +152 -156
- package/package/lib/test/inputSpecBuilder.test.js.map +1 -1
- package/package/lib/test/output.d.ts +2 -113
- package/package/lib/test/output.js +41 -40
- package/package/lib/test/output.js.map +1 -1
- package/package/lib/test/output.sdk.d.ts +235 -901
- package/package/lib/test/output.sdk.js +0 -1
- package/package/lib/test/output.sdk.js.map +1 -1
- package/package/lib/test/output.test.js +12 -8
- package/package/lib/test/output.test.js.map +1 -1
- package/package/lib/util/Drop.d.ts +4 -2
- package/package/lib/util/Drop.js +32 -8
- package/package/lib/util/Drop.js.map +1 -1
- package/package/lib/util/GetSslCertificate.d.ts +4 -0
- package/package/lib/util/GetSslCertificate.js +34 -2
- package/package/lib/util/GetSslCertificate.js.map +1 -1
- package/package/lib/util/SubContainer.d.ts +164 -45
- package/package/lib/util/SubContainer.js +223 -100
- package/package/lib/util/SubContainer.js.map +1 -1
- package/package/lib/util/fileHelper.d.ts +46 -17
- package/package/lib/util/fileHelper.js +112 -41
- package/package/lib/util/fileHelper.js.map +1 -1
- package/package/lib/version/VersionGraph.d.ts +26 -5
- package/package/lib/version/VersionGraph.js +88 -22
- package/package/lib/version/VersionGraph.js.map +1 -1
- package/package/package.json +63 -0
- package/package/scripts/oldSpecToBuilder.js +5 -4
- package/package/scripts/oldSpecToBuilder.js.map +1 -1
- package/package.json +7 -8
- package/base/lib/osBindings/NetworkInterfaceSetPublicParams.d.ts +0 -4
- package/base/lib/osBindings/NetworkInterfaceSetPublicParams.js.map +0 -1
- package/base/lib/osBindings/UnsetPublicParams.d.ts +0 -3
- package/base/lib/osBindings/UnsetPublicParams.js.map +0 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { HealthCheckResult } from "../health/checkFns";
|
|
2
2
|
import { Trigger } from "../trigger";
|
|
3
3
|
import * as T from "../../../base/lib/types";
|
|
4
|
-
import {
|
|
5
|
-
import { ExecSpawnable, MountOptions, SubContainer } from "../util/SubContainer";
|
|
4
|
+
import { SubContainer } from "../util/SubContainer";
|
|
6
5
|
import * as CP from "node:child_process";
|
|
7
6
|
export { Daemon } from "./Daemon";
|
|
8
7
|
export { CommandController } from "./CommandController";
|
|
9
8
|
import { HealthDaemon } from "./HealthDaemon";
|
|
10
9
|
import { Daemon } from "./Daemon";
|
|
11
10
|
import { CommandController } from "./CommandController";
|
|
12
|
-
import { HealthCheck } from "../health/HealthCheck";
|
|
13
11
|
export declare const cpExec: typeof CP.exec.__promisify__;
|
|
14
12
|
export declare const cpExecFile: typeof CP.execFile.__promisify__;
|
|
15
13
|
export type Ready = {
|
|
@@ -29,7 +27,7 @@ export type Ready = {
|
|
|
29
27
|
})
|
|
30
28
|
* ```
|
|
31
29
|
*/
|
|
32
|
-
fn: (
|
|
30
|
+
fn: () => Promise<HealthCheckResult> | HealthCheckResult;
|
|
33
31
|
/**
|
|
34
32
|
* A duration in milliseconds to treat a failing health check as "starting"
|
|
35
33
|
*
|
|
@@ -38,49 +36,48 @@ export type Ready = {
|
|
|
38
36
|
gracePeriod?: number;
|
|
39
37
|
trigger?: Trigger;
|
|
40
38
|
};
|
|
41
|
-
type
|
|
42
|
-
/** The command line command to start the daemon */
|
|
39
|
+
export type ExecCommandOptions = {
|
|
43
40
|
command: T.CommandType;
|
|
44
|
-
/** Information about the subcontainer in which the daemon runs */
|
|
45
|
-
subcontainer: {
|
|
46
|
-
/** The ID of the image. Must be one of the image IDs declared in the manifest */
|
|
47
|
-
imageId: keyof Manifest["images"] & T.ImageId;
|
|
48
|
-
/**
|
|
49
|
-
* Whether or not to share the `/run` directory with the parent container.
|
|
50
|
-
* This is useful if you are trying to connect to a service that exposes a unix domain socket or auth cookie via the `/run` directory
|
|
51
|
-
*/
|
|
52
|
-
sharedRun?: boolean;
|
|
53
|
-
} | SubContainer;
|
|
54
|
-
/** For mounting the necessary volumes. Syntax: sdk.Mounts.of().addVolume() */
|
|
55
|
-
mounts: Mounts<Manifest>;
|
|
56
|
-
env?: Record<string, string>;
|
|
57
|
-
ready: Ready;
|
|
58
|
-
/** An array of IDs of prior daemons whose successful initializations are required before this daemon will initialize */
|
|
59
|
-
requires: Exclude<Ids, Id>[];
|
|
60
|
-
sigtermTimeout?: number;
|
|
61
|
-
onStdout?: (chunk: Buffer | string | any) => void;
|
|
62
|
-
onStderr?: (chunk: Buffer | string | any) => void;
|
|
63
|
-
};
|
|
64
|
-
type ErrorDuplicateId<Id extends string> = `The id '${Id}' is already used`;
|
|
65
|
-
export declare const runCommand: <Manifest extends T.SDKManifest>() => (effects: T.Effects, subcontainer: SubContainer | {
|
|
66
|
-
imageId: keyof Manifest["images"] & string;
|
|
67
|
-
sharedRun?: boolean;
|
|
68
|
-
}, command: T.CommandType, options: {
|
|
69
|
-
subcontainerName?: string;
|
|
70
41
|
sigtermTimeout?: number;
|
|
71
|
-
mounts?: {
|
|
72
|
-
mountpoint: string;
|
|
73
|
-
options: MountOptions;
|
|
74
|
-
}[] | undefined;
|
|
75
42
|
runAsInit?: boolean;
|
|
76
43
|
env?: {
|
|
77
44
|
[variable: string]: string;
|
|
78
45
|
} | undefined;
|
|
79
46
|
cwd?: string | undefined;
|
|
80
47
|
user?: string | undefined;
|
|
81
|
-
onStdout?: (
|
|
82
|
-
onStderr?: (
|
|
83
|
-
}
|
|
48
|
+
onStdout?: (chunk: Buffer | string | any) => void;
|
|
49
|
+
onStderr?: (chunk: Buffer | string | any) => void;
|
|
50
|
+
};
|
|
51
|
+
export type ExecFnOptions<Manifest extends T.SDKManifest, C extends SubContainer<Manifest> | null> = {
|
|
52
|
+
fn: (subcontainer: C, abort: AbortController) => Promise<C extends null ? null : ExecCommandOptions | null>;
|
|
53
|
+
sigtermTimeout?: number;
|
|
54
|
+
};
|
|
55
|
+
export type DaemonCommandType<Manifest extends T.SDKManifest, C extends SubContainer<Manifest> | null> = ExecFnOptions<Manifest, C> | (C extends null ? never : ExecCommandOptions);
|
|
56
|
+
type NewDaemonParams<Manifest extends T.SDKManifest, C extends SubContainer<Manifest> | null> = {
|
|
57
|
+
/** What to run as the daemon: either an async fn or a commandline command to run in the subcontainer */
|
|
58
|
+
exec: DaemonCommandType<Manifest, C>;
|
|
59
|
+
/** The subcontainer in which the daemon runs */
|
|
60
|
+
subcontainer: C;
|
|
61
|
+
};
|
|
62
|
+
type AddDaemonParams<Manifest extends T.SDKManifest, Ids extends string, Id extends string, C extends SubContainer<Manifest> | null> = (NewDaemonParams<Manifest, C> | {
|
|
63
|
+
daemon: Daemon<Manifest>;
|
|
64
|
+
}) & {
|
|
65
|
+
ready: Ready;
|
|
66
|
+
/** An array of IDs of prior daemons whose successful initializations are required before this daemon will initialize */
|
|
67
|
+
requires: Exclude<Ids, Id>[];
|
|
68
|
+
};
|
|
69
|
+
type AddOneshotParams<Manifest extends T.SDKManifest, Ids extends string, Id extends string, C extends SubContainer<Manifest> | null> = NewDaemonParams<Manifest, C> & {
|
|
70
|
+
exec: DaemonCommandType<Manifest, C>;
|
|
71
|
+
/** An array of IDs of prior daemons whose successful initializations are required before this daemon will initialize */
|
|
72
|
+
requires: Exclude<Ids, Id>[];
|
|
73
|
+
};
|
|
74
|
+
type AddHealthCheckParams<Ids extends string, Id extends string> = {
|
|
75
|
+
ready: Ready;
|
|
76
|
+
/** An array of IDs of prior daemons whose successful initializations are required before this daemon will initialize */
|
|
77
|
+
requires: Exclude<Ids, Id>[];
|
|
78
|
+
};
|
|
79
|
+
type ErrorDuplicateId<Id extends string> = `The id '${Id}' is already used`;
|
|
80
|
+
export declare const runCommand: <Manifest extends T.SDKManifest>() => (effects: T.Effects, subcontainer: SubContainer<Manifest, T.Effects>, exec: DaemonCommandType<Manifest, SubContainer<Manifest, T.Effects>>) => Promise<CommandController<Manifest, SubContainer<Manifest, T.Effects>>>;
|
|
84
81
|
/**
|
|
85
82
|
* A class for defining and controlling the service daemons
|
|
86
83
|
```ts
|
|
@@ -106,11 +103,10 @@ Daemons.of({
|
|
|
106
103
|
*/
|
|
107
104
|
export declare class Daemons<Manifest extends T.SDKManifest, Ids extends string> implements T.DaemonBuildable {
|
|
108
105
|
readonly effects: T.Effects;
|
|
109
|
-
readonly started: (onTerm: () => PromiseLike<void>) => PromiseLike<null
|
|
110
|
-
readonly daemons: Promise<Daemon
|
|
106
|
+
readonly started: ((onTerm: () => PromiseLike<void>) => PromiseLike<null>) | null;
|
|
107
|
+
readonly daemons: Promise<Daemon<Manifest>>[];
|
|
111
108
|
readonly ids: Ids[];
|
|
112
|
-
readonly healthDaemons: HealthDaemon[];
|
|
113
|
-
readonly healthChecks: HealthCheck[];
|
|
109
|
+
readonly healthDaemons: HealthDaemon<Manifest>[];
|
|
114
110
|
private constructor();
|
|
115
111
|
/**
|
|
116
112
|
* Returns an empty new Daemons class with the provided inputSpec.
|
|
@@ -119,21 +115,48 @@ export declare class Daemons<Manifest extends T.SDKManifest, Ids extends string>
|
|
|
119
115
|
*
|
|
120
116
|
* Daemons run in the order they are defined, with latter daemons being capable of
|
|
121
117
|
* depending on prior daemons
|
|
122
|
-
*
|
|
118
|
+
*
|
|
119
|
+
* @param effects
|
|
120
|
+
*
|
|
121
|
+
* @param started
|
|
123
122
|
* @returns
|
|
124
123
|
*/
|
|
125
124
|
static of<Manifest extends T.SDKManifest>(options: {
|
|
126
125
|
effects: T.Effects;
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
/**
|
|
127
|
+
* A closure to run once the system is launched. If you are in main, provide the `started` argument you receive from the function arguments
|
|
128
|
+
*/
|
|
129
|
+
started: ((onTerm: () => PromiseLike<void>) => PromiseLike<null>) | null;
|
|
129
130
|
}): Daemons<Manifest, never>;
|
|
130
131
|
/**
|
|
131
132
|
* Returns the complete list of daemons, including the one defined here
|
|
132
133
|
* @param id
|
|
133
|
-
* @param
|
|
134
|
-
* @returns
|
|
134
|
+
* @param options
|
|
135
|
+
* @returns a new Daemons object
|
|
136
|
+
*/
|
|
137
|
+
addDaemon<Id extends string, C extends SubContainer<Manifest> | null>(id: "" extends Id ? never : ErrorDuplicateId<Id> extends Id ? never : Id extends Ids ? ErrorDuplicateId<Id> : Id, options: AddDaemonParams<Manifest, Ids, Id, C>): Daemons<Manifest, Ids | Id>;
|
|
138
|
+
/**
|
|
139
|
+
* Returns the complete list of daemons, including a "oneshot" daemon one defined here
|
|
140
|
+
* a oneshot daemon is a command that executes once when started, and is considered "running" once it exits successfully
|
|
141
|
+
* @param id
|
|
142
|
+
* @param options
|
|
143
|
+
* @returns a new Daemons object
|
|
144
|
+
*/
|
|
145
|
+
addOneshot<Id extends string, C extends SubContainer<Manifest> | null>(id: "" extends Id ? never : ErrorDuplicateId<Id> extends Id ? never : Id extends Ids ? ErrorDuplicateId<Id> : Id, options: AddOneshotParams<Manifest, Ids, Id, C>): Daemons<Manifest, Ids | Id>;
|
|
146
|
+
/**
|
|
147
|
+
* Returns the complete list of daemons, including a new HealthCheck defined here
|
|
148
|
+
* @param id
|
|
149
|
+
* @param options
|
|
150
|
+
* @returns a new Daemons object
|
|
151
|
+
*/
|
|
152
|
+
addHealthCheck<Id extends string>(id: "" extends Id ? never : ErrorDuplicateId<Id> extends Id ? never : Id extends Ids ? ErrorDuplicateId<Id> : Id, options: AddHealthCheckParams<Ids, Id>): Daemons<Manifest, Ids | Id>;
|
|
153
|
+
/**
|
|
154
|
+
* Runs the entire system until all daemons have returned `ready`.
|
|
155
|
+
* @param id
|
|
156
|
+
* @param options
|
|
157
|
+
* @returns a new Daemons object
|
|
135
158
|
*/
|
|
136
|
-
|
|
159
|
+
runUntilSuccess(timeout: number | null): Promise<null>;
|
|
137
160
|
term(): Promise<void>;
|
|
138
161
|
build(): Promise<this>;
|
|
139
162
|
}
|
|
@@ -43,6 +43,7 @@ Object.defineProperty(exports, "CommandController", { enumerable: true, get: fun
|
|
|
43
43
|
const HealthDaemon_1 = require("./HealthDaemon");
|
|
44
44
|
const Daemon_2 = require("./Daemon");
|
|
45
45
|
const CommandController_2 = require("./CommandController");
|
|
46
|
+
const Oneshot_1 = require("./Oneshot");
|
|
46
47
|
exports.cpExec = (0, node_util_1.promisify)(CP.exec);
|
|
47
48
|
exports.cpExecFile = (0, node_util_1.promisify)(CP.execFile);
|
|
48
49
|
const runCommand = () => CommandController_2.CommandController.of();
|
|
@@ -71,13 +72,12 @@ Daemons.of({
|
|
|
71
72
|
```
|
|
72
73
|
*/
|
|
73
74
|
class Daemons {
|
|
74
|
-
constructor(effects, started, daemons, ids, healthDaemons
|
|
75
|
+
constructor(effects, started, daemons, ids, healthDaemons) {
|
|
75
76
|
this.effects = effects;
|
|
76
77
|
this.started = started;
|
|
77
78
|
this.daemons = daemons;
|
|
78
79
|
this.ids = ids;
|
|
79
80
|
this.healthDaemons = healthDaemons;
|
|
80
|
-
this.healthChecks = healthChecks;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Returns an empty new Daemons class with the provided inputSpec.
|
|
@@ -86,40 +86,107 @@ class Daemons {
|
|
|
86
86
|
*
|
|
87
87
|
* Daemons run in the order they are defined, with latter daemons being capable of
|
|
88
88
|
* depending on prior daemons
|
|
89
|
-
*
|
|
89
|
+
*
|
|
90
|
+
* @param effects
|
|
91
|
+
*
|
|
92
|
+
* @param started
|
|
90
93
|
* @returns
|
|
91
94
|
*/
|
|
92
95
|
static of(options) {
|
|
93
|
-
return new Daemons(options.effects, options.started, [], [], []
|
|
96
|
+
return new Daemons(options.effects, options.started, [], [], []);
|
|
94
97
|
}
|
|
95
98
|
/**
|
|
96
99
|
* Returns the complete list of daemons, including the one defined here
|
|
97
100
|
* @param id
|
|
98
|
-
* @param
|
|
99
|
-
* @returns
|
|
101
|
+
* @param options
|
|
102
|
+
* @returns a new Daemons object
|
|
100
103
|
*/
|
|
101
104
|
addDaemon(
|
|
102
105
|
// prettier-ignore
|
|
103
106
|
id, options) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
const daemon = "daemon" in options
|
|
108
|
+
? Promise.resolve(options.daemon)
|
|
109
|
+
: Daemon_2.Daemon.of()(this.effects, options.subcontainer, options.exec);
|
|
110
|
+
const healthDaemon = new HealthDaemon_1.HealthDaemon(daemon, options.requires
|
|
111
|
+
.map((x) => this.ids.indexOf(x))
|
|
112
|
+
.filter((x) => x >= 0)
|
|
113
|
+
.map((id) => this.healthDaemons[id]), id, options.ready, this.effects);
|
|
114
|
+
const daemons = [...this.daemons, daemon];
|
|
115
|
+
const ids = [...this.ids, id];
|
|
116
|
+
const healthDaemons = [...this.healthDaemons, healthDaemon];
|
|
117
|
+
return new Daemons(this.effects, this.started, daemons, ids, healthDaemons);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns the complete list of daemons, including a "oneshot" daemon one defined here
|
|
121
|
+
* a oneshot daemon is a command that executes once when started, and is considered "running" once it exits successfully
|
|
122
|
+
* @param id
|
|
123
|
+
* @param options
|
|
124
|
+
* @returns a new Daemons object
|
|
125
|
+
*/
|
|
126
|
+
addOneshot(id, options) {
|
|
127
|
+
const daemon = Oneshot_1.Oneshot.of()(this.effects, options.subcontainer, options.exec);
|
|
128
|
+
const healthDaemon = new HealthDaemon_1.HealthDaemon(daemon, options.requires
|
|
129
|
+
.map((x) => this.ids.indexOf(x))
|
|
130
|
+
.filter((x) => x >= 0)
|
|
131
|
+
.map((id) => this.healthDaemons[id]), id, "EXIT_SUCCESS", this.effects);
|
|
132
|
+
const daemons = [...this.daemons, daemon];
|
|
133
|
+
const ids = [...this.ids, id];
|
|
134
|
+
const healthDaemons = [...this.healthDaemons, healthDaemon];
|
|
135
|
+
return new Daemons(this.effects, this.started, daemons, ids, healthDaemons);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Returns the complete list of daemons, including a new HealthCheck defined here
|
|
139
|
+
* @param id
|
|
140
|
+
* @param options
|
|
141
|
+
* @returns a new Daemons object
|
|
142
|
+
*/
|
|
143
|
+
addHealthCheck(id, options) {
|
|
144
|
+
const healthDaemon = new HealthDaemon_1.HealthDaemon(null, options.requires
|
|
111
145
|
.map((x) => this.ids.indexOf(x))
|
|
112
146
|
.filter((x) => x >= 0)
|
|
113
|
-
.map((id) => this.healthDaemons[id]), id,
|
|
114
|
-
const daemons = this.daemons
|
|
147
|
+
.map((id) => this.healthDaemons[id]), id, options.ready, this.effects);
|
|
148
|
+
const daemons = [...this.daemons];
|
|
115
149
|
const ids = [...this.ids, id];
|
|
116
150
|
const healthDaemons = [...this.healthDaemons, healthDaemon];
|
|
117
|
-
return new Daemons(this.effects, this.started, daemons, ids, healthDaemons
|
|
151
|
+
return new Daemons(this.effects, this.started, daemons, ids, healthDaemons);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Runs the entire system until all daemons have returned `ready`.
|
|
155
|
+
* @param id
|
|
156
|
+
* @param options
|
|
157
|
+
* @returns a new Daemons object
|
|
158
|
+
*/
|
|
159
|
+
async runUntilSuccess(timeout) {
|
|
160
|
+
let resolve = (_) => { };
|
|
161
|
+
const res = new Promise((res, rej) => {
|
|
162
|
+
resolve = res;
|
|
163
|
+
if (timeout)
|
|
164
|
+
setTimeout(() => {
|
|
165
|
+
const notReady = this.healthDaemons
|
|
166
|
+
.filter((d) => !d.isReady)
|
|
167
|
+
.map((d) => d.id);
|
|
168
|
+
rej(new Error(`Timed out waiting for ${notReady}`));
|
|
169
|
+
}, timeout);
|
|
170
|
+
});
|
|
171
|
+
const daemon = Oneshot_1.Oneshot.of()(this.effects, null, {
|
|
172
|
+
fn: async () => {
|
|
173
|
+
resolve();
|
|
174
|
+
return null;
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
const healthDaemon = new HealthDaemon_1.HealthDaemon(daemon, [...this.healthDaemons], "__RUN_UNTIL_SUCCESS", "EXIT_SUCCESS", this.effects);
|
|
178
|
+
const daemons = await new Daemons(this.effects, this.started, [...this.daemons, daemon], this.ids, [...this.healthDaemons, healthDaemon]).build();
|
|
179
|
+
try {
|
|
180
|
+
await res;
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
await daemons.term();
|
|
184
|
+
}
|
|
185
|
+
return null;
|
|
118
186
|
}
|
|
119
187
|
async term() {
|
|
120
188
|
try {
|
|
121
|
-
this.
|
|
122
|
-
for (let result of await Promise.allSettled(this.healthDaemons.map((x) => x.term({ timeout: x.sigtermTimeout })))) {
|
|
189
|
+
for (let result of await Promise.allSettled(this.healthDaemons.map((x) => x.term()))) {
|
|
123
190
|
if (result.status === "rejected") {
|
|
124
191
|
console.error(result.reason);
|
|
125
192
|
}
|
|
@@ -131,12 +198,9 @@ class Daemons {
|
|
|
131
198
|
}
|
|
132
199
|
async build() {
|
|
133
200
|
for (const daemon of this.healthDaemons) {
|
|
134
|
-
await daemon.
|
|
135
|
-
}
|
|
136
|
-
for (const health of this.healthChecks) {
|
|
137
|
-
health.start();
|
|
201
|
+
await daemon.init();
|
|
138
202
|
}
|
|
139
|
-
this.started(() => this.term());
|
|
203
|
+
this.started?.(() => this.term());
|
|
140
204
|
return this;
|
|
141
205
|
}
|
|
142
206
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Daemons.js","sourceRoot":"","sources":["../../../../package/lib/mainFn/Daemons.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Daemons.js","sourceRoot":"","sources":["../../../../package/lib/mainFn/Daemons.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,yCAAqC;AACrC,uDAAwC;AAExC,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,yDAAuD;AAA9C,sHAAA,iBAAiB,OAAA;AAC1B,iDAA6C;AAC7C,q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,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,KAAK,IAAI,MAAM,IAAI,MAAM,OAAO,CAAC,UAAU,CACzC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CACxC,EAAE,CAAC;gBACF,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;oBACjC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAA;QACnD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACxC,MAAM,MAAM,CAAC,IAAI,EAAE,CAAA;QACrB,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA1OD,0BA0OC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HealthCheckResult } from "../health/checkFns";
|
|
2
2
|
import { Ready } from "./Daemons";
|
|
3
3
|
import { Daemon } from "./Daemon";
|
|
4
|
-
import { Effects } from "../../../base/lib/types";
|
|
4
|
+
import { Effects, SDKManifest } from "../../../base/lib/types";
|
|
5
|
+
export declare const EXIT_SUCCESS: "EXIT_SUCCESS";
|
|
5
6
|
/**
|
|
6
7
|
* Wanted a structure that deals with controlling daemons by their health status
|
|
7
8
|
* States:
|
|
@@ -9,22 +10,20 @@ import { Effects } from "../../../base/lib/types";
|
|
|
9
10
|
* -- Running: Daemon is running and the status is in the health
|
|
10
11
|
*
|
|
11
12
|
*/
|
|
12
|
-
export declare class HealthDaemon {
|
|
13
|
+
export declare class HealthDaemon<Manifest extends SDKManifest> {
|
|
13
14
|
private readonly daemon;
|
|
14
|
-
readonly daemonIndex: number;
|
|
15
15
|
private readonly dependencies;
|
|
16
16
|
readonly id: string;
|
|
17
|
-
readonly
|
|
18
|
-
readonly ready: Ready;
|
|
17
|
+
readonly ready: Ready | typeof EXIT_SUCCESS;
|
|
19
18
|
readonly effects: Effects;
|
|
20
|
-
readonly sigtermTimeout: number;
|
|
21
19
|
private _health;
|
|
22
20
|
private healthWatchers;
|
|
23
21
|
private running;
|
|
24
22
|
private started?;
|
|
25
23
|
private resolveReady;
|
|
24
|
+
private resolvedReady;
|
|
26
25
|
private readyPromise;
|
|
27
|
-
constructor(daemon: Promise<Daemon
|
|
26
|
+
constructor(daemon: Promise<Daemon<Manifest>> | null, dependencies: HealthDaemon<Manifest>[], id: string, ready: Ready | typeof EXIT_SUCCESS, effects: Effects);
|
|
28
27
|
/** Run after we want to do cleanup */
|
|
29
28
|
term(termOptions?: {
|
|
30
29
|
signal?: NodeJS.Signals | undefined;
|
|
@@ -38,6 +37,8 @@ export declare class HealthDaemon {
|
|
|
38
37
|
private turnOffHealthCheck;
|
|
39
38
|
private setupHealthCheck;
|
|
40
39
|
onReady(): Promise<void>;
|
|
40
|
+
get isReady(): boolean;
|
|
41
41
|
private setHealth;
|
|
42
42
|
updateStatus(): Promise<void>;
|
|
43
|
+
init(): Promise<void>;
|
|
43
44
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HealthDaemon = void 0;
|
|
3
|
+
exports.HealthDaemon = exports.EXIT_SUCCESS = void 0;
|
|
4
4
|
const defaultTrigger_1 = require("../trigger/defaultTrigger");
|
|
5
|
-
const _1 = require(".");
|
|
6
5
|
const asError_1 = require("../../../base/lib/util/asError");
|
|
7
6
|
const oncePromise = () => {
|
|
8
7
|
let resolve;
|
|
@@ -11,6 +10,7 @@ const oncePromise = () => {
|
|
|
11
10
|
});
|
|
12
11
|
return { resolve: resolve, promise };
|
|
13
12
|
};
|
|
13
|
+
exports.EXIT_SUCCESS = "EXIT_SUCCESS";
|
|
14
14
|
/**
|
|
15
15
|
* Wanted a structure that deals with controlling daemons by their health status
|
|
16
16
|
* States:
|
|
@@ -19,20 +19,21 @@ const oncePromise = () => {
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
class HealthDaemon {
|
|
22
|
-
constructor(daemon,
|
|
22
|
+
constructor(daemon, dependencies, id, ready, effects) {
|
|
23
23
|
this.daemon = daemon;
|
|
24
|
-
this.daemonIndex = daemonIndex;
|
|
25
24
|
this.dependencies = dependencies;
|
|
26
25
|
this.id = id;
|
|
27
|
-
this.ids = ids;
|
|
28
26
|
this.ready = ready;
|
|
29
27
|
this.effects = effects;
|
|
30
|
-
this.sigtermTimeout = sigtermTimeout;
|
|
31
28
|
this._health = { result: "starting", message: null };
|
|
32
29
|
this.healthWatchers = [];
|
|
33
30
|
this.running = false;
|
|
31
|
+
this.resolvedReady = false;
|
|
34
32
|
this.healthCheckCleanup = null;
|
|
35
|
-
this.readyPromise = new Promise((resolve) => (this.resolveReady =
|
|
33
|
+
this.readyPromise = new Promise((resolve) => (this.resolveReady = () => {
|
|
34
|
+
resolve();
|
|
35
|
+
this.resolvedReady = true;
|
|
36
|
+
}));
|
|
36
37
|
this.dependencies.forEach((d) => d.addWatcher(() => this.updateStatus()));
|
|
37
38
|
}
|
|
38
39
|
/** Run after we want to do cleanup */
|
|
@@ -40,8 +41,7 @@ class HealthDaemon {
|
|
|
40
41
|
this.healthWatchers = [];
|
|
41
42
|
this.running = false;
|
|
42
43
|
this.healthCheckCleanup?.();
|
|
43
|
-
await this.daemon
|
|
44
|
-
timeout: this.sigtermTimeout,
|
|
44
|
+
await this.daemon?.then((d) => d.term({
|
|
45
45
|
...termOptions,
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
@@ -57,22 +57,47 @@ class HealthDaemon {
|
|
|
57
57
|
return;
|
|
58
58
|
this.running = newStatus;
|
|
59
59
|
if (newStatus) {
|
|
60
|
-
;
|
|
61
|
-
(await this.daemon).start();
|
|
62
|
-
this.started = performance.now();
|
|
60
|
+
console.debug(`Launching ${this.id}...`);
|
|
63
61
|
this.setupHealthCheck();
|
|
62
|
+
(await this.daemon)?.start();
|
|
63
|
+
this.started = performance.now();
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
;
|
|
67
|
-
(await this.daemon)
|
|
66
|
+
console.debug(`Stopping ${this.id}...`);
|
|
67
|
+
(await this.daemon)?.stop();
|
|
68
68
|
this.turnOffHealthCheck();
|
|
69
69
|
this.setHealth({ result: "starting", message: null });
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
turnOffHealthCheck() {
|
|
73
73
|
this.healthCheckCleanup?.();
|
|
74
|
+
this.resolvedReady = false;
|
|
75
|
+
this.readyPromise = new Promise((resolve) => (this.resolveReady = () => {
|
|
76
|
+
resolve();
|
|
77
|
+
this.resolvedReady = true;
|
|
78
|
+
}));
|
|
74
79
|
}
|
|
75
80
|
async setupHealthCheck() {
|
|
81
|
+
const daemon = await this.daemon;
|
|
82
|
+
daemon?.onExit((success) => {
|
|
83
|
+
if (success && this.ready === "EXIT_SUCCESS") {
|
|
84
|
+
this.setHealth({ result: "success", message: null });
|
|
85
|
+
}
|
|
86
|
+
else if (!success) {
|
|
87
|
+
this.setHealth({
|
|
88
|
+
result: "failure",
|
|
89
|
+
message: `${this.id} daemon crashed`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (!daemon.isOneshot()) {
|
|
93
|
+
this.setHealth({
|
|
94
|
+
result: "failure",
|
|
95
|
+
message: `${this.id} daemon exited`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
if (this.ready === "EXIT_SUCCESS")
|
|
100
|
+
return;
|
|
76
101
|
if (this.healthCheckCleanup)
|
|
77
102
|
return;
|
|
78
103
|
const trigger = (this.ready.trigger ?? defaultTrigger_1.defaultTrigger)(() => ({
|
|
@@ -80,28 +105,17 @@ class HealthDaemon {
|
|
|
80
105
|
}));
|
|
81
106
|
const { promise: status, resolve: setStatus } = oncePromise();
|
|
82
107
|
new Promise(async () => {
|
|
108
|
+
if (this.ready === "EXIT_SUCCESS")
|
|
109
|
+
return;
|
|
83
110
|
for (let res = await Promise.race([status, trigger.next()]); !res.done; res = await Promise.race([status, trigger.next()])) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.error((0, asError_1.asError)(err));
|
|
88
|
-
return {
|
|
89
|
-
result: "failure",
|
|
90
|
-
message: "message" in err ? err.message : String(err),
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
if (this.resolveReady &&
|
|
94
|
-
(response.result === "success" || response.result === "disabled")) {
|
|
95
|
-
this.resolveReady();
|
|
96
|
-
}
|
|
97
|
-
await this.setHealth(response);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
await this.setHealth({
|
|
111
|
+
const response = await Promise.resolve(this.ready.fn()).catch((err) => {
|
|
112
|
+
console.error((0, asError_1.asError)(err));
|
|
113
|
+
return {
|
|
101
114
|
result: "failure",
|
|
102
|
-
message: "
|
|
103
|
-
}
|
|
104
|
-
}
|
|
115
|
+
message: "message" in err ? err.message : String(err),
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
await this.setHealth(response);
|
|
105
119
|
}
|
|
106
120
|
}).catch((err) => console.error(`Daemon ${this.id} failed: ${err}`));
|
|
107
121
|
this.healthCheckCleanup = () => {
|
|
@@ -113,9 +127,19 @@ class HealthDaemon {
|
|
|
113
127
|
onReady() {
|
|
114
128
|
return this.readyPromise;
|
|
115
129
|
}
|
|
130
|
+
get isReady() {
|
|
131
|
+
return this.resolvedReady;
|
|
132
|
+
}
|
|
116
133
|
async setHealth(health) {
|
|
134
|
+
const changed = this._health.result !== health.result;
|
|
117
135
|
this._health = health;
|
|
118
|
-
this.
|
|
136
|
+
if (this.resolveReady && health.result === "success") {
|
|
137
|
+
this.resolveReady();
|
|
138
|
+
}
|
|
139
|
+
if (changed)
|
|
140
|
+
this.healthWatchers.forEach((watcher) => watcher());
|
|
141
|
+
if (this.ready === "EXIT_SUCCESS")
|
|
142
|
+
return;
|
|
119
143
|
const display = this.ready.display;
|
|
120
144
|
if (!display) {
|
|
121
145
|
return;
|
|
@@ -123,7 +147,7 @@ class HealthDaemon {
|
|
|
123
147
|
let result = health.result;
|
|
124
148
|
if (result === "failure" &&
|
|
125
149
|
this.started &&
|
|
126
|
-
performance.now() - this.started <= (this.ready.gracePeriod ??
|
|
150
|
+
performance.now() - this.started <= (this.ready.gracePeriod ?? 10_000))
|
|
127
151
|
result = "starting";
|
|
128
152
|
await this.effects.setHealth({
|
|
129
153
|
...health,
|
|
@@ -133,8 +157,25 @@ class HealthDaemon {
|
|
|
133
157
|
});
|
|
134
158
|
}
|
|
135
159
|
async updateStatus() {
|
|
136
|
-
const healths = this.dependencies.map((d) =>
|
|
137
|
-
|
|
160
|
+
const healths = this.dependencies.map((d) => ({
|
|
161
|
+
health: d.running && d._health,
|
|
162
|
+
id: d.id,
|
|
163
|
+
}));
|
|
164
|
+
const waitingOn = healths.filter((h) => !h.health || h.health.result !== "success");
|
|
165
|
+
if (waitingOn.length)
|
|
166
|
+
console.debug(`daemon ${this.id} waiting on ${waitingOn.map((w) => w.id)}`);
|
|
167
|
+
this.changeRunning(!waitingOn.length);
|
|
168
|
+
}
|
|
169
|
+
async init() {
|
|
170
|
+
if (this.ready !== "EXIT_SUCCESS" && this.ready.display) {
|
|
171
|
+
this.effects.setHealth({
|
|
172
|
+
id: this.id,
|
|
173
|
+
message: null,
|
|
174
|
+
name: this.ready.display,
|
|
175
|
+
result: "starting",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
await this.updateStatus();
|
|
138
179
|
}
|
|
139
180
|
}
|
|
140
181
|
exports.HealthDaemon = HealthDaemon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HealthDaemon.js","sourceRoot":"","sources":["../../../../package/lib/mainFn/HealthDaemon.ts"],"names":[],"mappings":";;;AACA,8DAA0D;
|
|
1
|
+
{"version":3,"file":"HealthDaemon.js","sourceRoot":"","sources":["../../../../package/lib/mainFn/HealthDaemon.ts"],"names":[],"mappings":";;;AACA,8DAA0D;AAK1D,4DAAwD;AAIxD,MAAM,WAAW,GAAG,GAAM,EAAE;IAC1B,IAAI,OAA2B,CAAA;IAC/B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,GAAG,EAAE,EAAE;QACrC,OAAO,GAAG,GAAG,CAAA;IACf,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,OAAO,EAAE,OAAQ,EAAE,OAAO,EAAE,CAAA;AACvC,CAAC,CAAA;AAEY,QAAA,YAAY,GAAG,cAAuB,CAAA;AAEnD;;;;;;GAMG;AACH,MAAa,YAAY;IAQvB,YACmB,MAAwC,EACxC,YAAsC,EAC9C,EAAU,EACV,KAAkC,EAClC,OAAgB;QAJR,WAAM,GAAN,MAAM,CAAkC;QACxC,iBAAY,GAAZ,YAAY,CAA0B;QAC9C,OAAE,GAAF,EAAE,CAAQ;QACV,UAAK,GAAL,KAAK,CAA6B;QAClC,YAAO,GAAP,OAAO,CAAS;QAZnB,YAAO,GAAsB,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QAClE,mBAAc,GAAyB,EAAE,CAAA;QACzC,YAAO,GAAG,KAAK,CAAA;QAGf,kBAAa,GAAY,KAAK,CAAA;QA+D9B,uBAAkB,GAAwB,IAAI,CAAA;QAtDpD,IAAI,CAAC,YAAY,GAAG,IAAI,OAAO,CAC7B,CAAC,OAAO,EAAE,EAAE,CACV,CAAC,IAAI,CAAC,YAAY,GAAG,GAAG,EAAE;YACxB,OAAO,EAAE,CAAA;YACT,IAAI,CAAC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