@procedures/server 0.41.0 → 0.42.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/CHANGELOG.md +31 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/host.d.ts +11 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +31 -2
- package/dist/host.js.map +1 -1
- package/dist/idle.d.ts +56 -0
- package/dist/idle.d.ts.map +1 -0
- package/dist/idle.js +90 -0
- package/dist/idle.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/procedures/server.start.d.ts +39 -0
- package/dist/procedures/server.start.d.ts.map +1 -1
- package/dist/procedures/server.start.js +76 -38
- package/dist/procedures/server.start.js.map +1 -1
- package/package.json +6 -6
- package/src/host.ts +40 -2
- package/src/idle.ts +119 -0
- package/src/index.ts +3 -1
- package/src/procedures/server.start.ts +113 -46
package/dist/host.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ import { type ProbeKind } from "@mark1russell7/service/http";
|
|
|
23
23
|
import { type Duration } from "@procedures/client";
|
|
24
24
|
import { type ProcedureHost, type ProcedureHostOptions } from "@procedures/peer";
|
|
25
25
|
import { type LockfileData } from "@procedures/peer/lockfile";
|
|
26
|
+
import { type HostIdle } from "./idle.js";
|
|
26
27
|
/** The mode of a run: in the foreground of a terminal, or as the background host of `mark`. */
|
|
27
28
|
export type HostRunMode = "foreground" | "background";
|
|
28
29
|
/** The profile of each mode, as data: `localDev` in the foreground, and `daemon` in the background. */
|
|
@@ -85,6 +86,16 @@ export interface ProcedureHostRunConfig {
|
|
|
85
86
|
* The return value has no effect.
|
|
86
87
|
*/
|
|
87
88
|
readonly declare?: ((svc: ServiceBuilder, host: ProcedureHost) => void) | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The idle stop (CLI-27): the host stops by itself after this time with no call. Without it, the
|
|
91
|
+
* host stops only at a signal or a stop request, as before.
|
|
92
|
+
*
|
|
93
|
+
* - Each call resets the timer at its start and at its end. An open stream or subscription is a
|
|
94
|
+
* call in flight, and the host does not stop while it is open.
|
|
95
|
+
* - The stop is `life.shutdown()` with the exit code 0. Thus the stop in stages of `run()` applies,
|
|
96
|
+
* and the lockfile goes at the end.
|
|
97
|
+
*/
|
|
98
|
+
readonly idle?: HostIdle | undefined;
|
|
88
99
|
}
|
|
89
100
|
/** A host that runs under `run()`: the host, the service of the process and its lifecycle. */
|
|
90
101
|
export interface RunningHost {
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAA6B,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvI,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAA6B,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvI,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAkC,KAAK,QAAQ,EAAqC,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAA6C,KAAK,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC5H,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAyC,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEjF,+FAA+F;AAC/F,M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OAcG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACpF;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACtC;AAED,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,gIAAgI;IAChI,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;;OAGG;IACH,MAAM,IAAI,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,CAAC,CAkE3F"}
|
package/dist/host.js
CHANGED
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { daemon, localDev, service } from "@mark1russell7/service";
|
|
22
22
|
import { probeServer } from "@mark1russell7/service/http";
|
|
23
|
-
import { seconds } from "@procedures/client";
|
|
23
|
+
import { hostPolicy, realClock, seconds } from "@procedures/client";
|
|
24
24
|
import { LOCAL_LISTENER_KNOBS, createProcedureHost } from "@procedures/peer";
|
|
25
25
|
import { lockfileHandle } from "@procedures/peer/lockfile";
|
|
26
|
+
import { idleInterceptor, idleTimer, idleTimes } from "./idle.js";
|
|
26
27
|
/** The profile of each mode, as data: `localDev` in the foreground, and `daemon` in the background. */
|
|
27
28
|
export const HOST_PROFILES = Object.freeze({ foreground: localDev, background: daemon });
|
|
28
29
|
/**
|
|
@@ -34,8 +35,26 @@ export async function runProcedureHost(config) {
|
|
|
34
35
|
const clock = config.run?.clock;
|
|
35
36
|
// A probe server of its own: the listeners of the host then answer no probes, unless the host options say so (D5)
|
|
36
37
|
const dedicated = config.probes;
|
|
38
|
+
// The idle stop (CLI-27): an interceptor of the policy tells the timer about each call. The timer
|
|
39
|
+
// starts after the startup, and it asks the lifecycle for the stop.
|
|
40
|
+
let life;
|
|
41
|
+
const idle = config.idle
|
|
42
|
+
? idleTimer({
|
|
43
|
+
...idleTimes(config.idle),
|
|
44
|
+
clock: clock ?? realClock,
|
|
45
|
+
inFlight: () => life?.inFlight() ?? 0,
|
|
46
|
+
stop: (cause) => {
|
|
47
|
+
if (life?.state !== "running")
|
|
48
|
+
return;
|
|
49
|
+
config.log?.(`\nIdle: ${cause}.`);
|
|
50
|
+
void life.shutdown(cause, { code: 0 });
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
: undefined;
|
|
54
|
+
const policy = idle ? withInterceptor(config.host.policy ?? hostPolicy(), idleInterceptor(idle)) : config.host.policy;
|
|
37
55
|
const host = createProcedureHost({
|
|
38
56
|
...config.host,
|
|
57
|
+
...(policy ? { policy } : {}),
|
|
39
58
|
...(clock ? { clock } : {}),
|
|
40
59
|
...(dedicated && config.host.probes === undefined ? { probes: false } : {}),
|
|
41
60
|
});
|
|
@@ -71,7 +90,13 @@ export async function runProcedureHost(config) {
|
|
|
71
90
|
const log = config.log;
|
|
72
91
|
if (log && profile.phases?.some((phase) => phase.name === "stop intake"))
|
|
73
92
|
svc.onPhase("stop intake", () => log("\nShutting down..."));
|
|
74
|
-
|
|
93
|
+
life = await svc.run(config.run);
|
|
94
|
+
if (idle) {
|
|
95
|
+
// The timer stops with the lifecycle, also after a stop for another cause
|
|
96
|
+
void life.done.then(() => idle.cancel());
|
|
97
|
+
if (life.state === "running")
|
|
98
|
+
idle.start();
|
|
99
|
+
}
|
|
75
100
|
const probeBase = () => {
|
|
76
101
|
const address = probes?.server.address();
|
|
77
102
|
if (typeof address !== "object" || address === null)
|
|
@@ -82,4 +107,8 @@ export async function runProcedureHost(config) {
|
|
|
82
107
|
};
|
|
83
108
|
return { host, service: svc, life, probes: () => (probes ? probeBase() : host.info.probes()) };
|
|
84
109
|
}
|
|
110
|
+
/** This function gives a policy with one more interceptor, after the interceptors of the policy. */
|
|
111
|
+
function withInterceptor(policy, interceptor) {
|
|
112
|
+
return { ...policy, interceptors: [...policy.interceptors, interceptor] };
|
|
113
|
+
}
|
|
85
114
|
//# sourceMappingURL=host.js.map
|
package/dist/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAsE,MAAM,wBAAwB,CAAC;AACvI,OAAO,EAAE,WAAW,EAAkB,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAsE,MAAM,wBAAwB,CAAC;AACvI,OAAO,EAAE,WAAW,EAAkB,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAoD,MAAM,oBAAoB,CAAC;AACtH,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAiD,MAAM,kBAAkB,CAAC;AAC5H,OAAO,EAAE,cAAc,EAAqB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAiB,MAAM,WAAW,CAAC;AAKjF,uGAAuG;AACvG,MAAM,CAAC,MAAM,aAAa,GAA2C,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;AAsFjI;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAA8B;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,EAA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AAa,EAAE;QAC/B,MAAM,OAAO,GAAG,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAC/D,MAAM,KAAK,GAAG,SAAS,EAAE,IAAI,IAAI,WAAW,CAAC;QAC7C,MAAM,KAAK,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1E,OAAO,CAAC,UAAU,KAAK,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;AACjG,CAAC;AAED,oGAAoG;AACpG,SAAS,eAAe,CAAC,MAAkB,EAAE,WAAwB;IACnE,OAAO,EAAE,GAAG,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC;AAC5E,CAAC"}
|
package/dist/idle.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The idle stop of a procedures host (CLI-27).
|
|
3
|
+
*
|
|
4
|
+
* A host with the option `idle` of `runProcedureHost()` stops by itself after a time with no call.
|
|
5
|
+
* The background host that `mark` starts after a cold command uses it (`MARK_AUTO_WARM`).
|
|
6
|
+
*
|
|
7
|
+
* - `run()` of `@mark1russell7/service` has no idle trigger. The host uses the stop request of the
|
|
8
|
+
* lifecycle, `life.shutdown()`, as an exit signal does. Thus the runner keeps the stop in stages
|
|
9
|
+
* and the exit, and this file has no signal handler, no listener and no `process.exit`.
|
|
10
|
+
* - An interceptor of the host policy resets the timer at the start and at the end of each call.
|
|
11
|
+
* - When the timer fires and a call is in flight (`life.inFlight()`), the host does not stop. An
|
|
12
|
+
* open stream or subscription is a call in flight until its last item (decision D4). The timer
|
|
13
|
+
* then reads the count again at each poll, and the full time starts again after the last call ends.
|
|
14
|
+
* - The timer uses the clock of the run, so a test gives a fake clock.
|
|
15
|
+
*/
|
|
16
|
+
import { type Clock, type Duration, type Interceptor } from "@procedures/client";
|
|
17
|
+
/** The default time between two reads of the calls in flight while a call is open: 5 s. */
|
|
18
|
+
export declare const IDLE_POLL_MS = 5000;
|
|
19
|
+
/** The option `idle` of `runProcedureHost()`. */
|
|
20
|
+
export interface HostIdle {
|
|
21
|
+
/** The time with no call, after which the host stops. */
|
|
22
|
+
readonly after: Duration;
|
|
23
|
+
/** The time between two reads of the calls in flight while a call is open. The default is 5 s, or `after` when it is shorter. */
|
|
24
|
+
readonly poll?: Duration | undefined;
|
|
25
|
+
}
|
|
26
|
+
/** The options of `idleTimer()`. */
|
|
27
|
+
export interface IdleTimerOptions {
|
|
28
|
+
/** The time with no call, in milliseconds. */
|
|
29
|
+
readonly afterMs: number;
|
|
30
|
+
/** The time between two reads of the calls in flight while a call is open, in milliseconds. */
|
|
31
|
+
readonly pollMs: number;
|
|
32
|
+
readonly clock: Clock;
|
|
33
|
+
/** This function gives the count of the calls in flight. */
|
|
34
|
+
readonly inFlight: () => number;
|
|
35
|
+
/** This function stops the host. The timer calls it one time, with the cause of the stop. */
|
|
36
|
+
readonly stop: (cause: string) => void;
|
|
37
|
+
}
|
|
38
|
+
/** The timer of the idle stop. */
|
|
39
|
+
export interface IdleTimer {
|
|
40
|
+
/** This method starts the timer. Before the start, `touch()` has no effect. */
|
|
41
|
+
start(): void;
|
|
42
|
+
/** This method tells the timer about a call: the full time starts again. */
|
|
43
|
+
touch(): void;
|
|
44
|
+
/** This method stops the timer for good. */
|
|
45
|
+
cancel(): void;
|
|
46
|
+
}
|
|
47
|
+
/** This function gives the timer of an idle stop. */
|
|
48
|
+
export declare function idleTimer(options: IdleTimerOptions): IdleTimer;
|
|
49
|
+
/** The timer of the option `idle` of a host, in milliseconds. */
|
|
50
|
+
export declare function idleTimes(idle: HostIdle): {
|
|
51
|
+
afterMs: number;
|
|
52
|
+
pollMs: number;
|
|
53
|
+
};
|
|
54
|
+
/** This function gives the interceptor that tells a timer about each call: at its start and at its end. */
|
|
55
|
+
export declare function idleInterceptor(timer: Pick<IdleTimer, "touch">): Interceptor;
|
|
56
|
+
//# sourceMappingURL=idle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle.d.ts","sourceRoot":"","sources":["../src/idle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAQ,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEvF,2FAA2F;AAC3F,eAAO,MAAM,YAAY,OAAQ,CAAC;AAElC,iDAAiD;AACjD,MAAM,WAAW,QAAQ;IACvB,yDAAyD;IACzD,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,iIAAiI;IACjI,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CACtC;AAED,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,MAAM,CAAC;IAChC,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,kCAAkC;AAClC,MAAM,WAAW,SAAS;IACxB,+EAA+E;IAC/E,KAAK,IAAI,IAAI,CAAC;IACd,4EAA4E;IAC5E,KAAK,IAAI,IAAI,CAAC;IACd,4CAA4C;IAC5C,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CA4C9D;AAED,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAM7E;AAED,2GAA2G;AAC3G,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,WAAW,CAS5E"}
|
package/dist/idle.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The idle stop of a procedures host (CLI-27).
|
|
3
|
+
*
|
|
4
|
+
* A host with the option `idle` of `runProcedureHost()` stops by itself after a time with no call.
|
|
5
|
+
* The background host that `mark` starts after a cold command uses it (`MARK_AUTO_WARM`).
|
|
6
|
+
*
|
|
7
|
+
* - `run()` of `@mark1russell7/service` has no idle trigger. The host uses the stop request of the
|
|
8
|
+
* lifecycle, `life.shutdown()`, as an exit signal does. Thus the runner keeps the stop in stages
|
|
9
|
+
* and the exit, and this file has no signal handler, no listener and no `process.exit`.
|
|
10
|
+
* - An interceptor of the host policy resets the timer at the start and at the end of each call.
|
|
11
|
+
* - When the timer fires and a call is in flight (`life.inFlight()`), the host does not stop. An
|
|
12
|
+
* open stream or subscription is a call in flight until its last item (decision D4). The timer
|
|
13
|
+
* then reads the count again at each poll, and the full time starts again after the last call ends.
|
|
14
|
+
* - The timer uses the clock of the run, so a test gives a fake clock.
|
|
15
|
+
*/
|
|
16
|
+
import { toMs } from "@procedures/client";
|
|
17
|
+
/** The default time between two reads of the calls in flight while a call is open: 5 s. */
|
|
18
|
+
export const IDLE_POLL_MS = 5_000;
|
|
19
|
+
/** This function gives the timer of an idle stop. */
|
|
20
|
+
export function idleTimer(options) {
|
|
21
|
+
const { afterMs, pollMs, clock } = options;
|
|
22
|
+
let started = false;
|
|
23
|
+
let ended = false;
|
|
24
|
+
// True when the last fire found a call in flight: the full time starts after that call ends
|
|
25
|
+
let open = false;
|
|
26
|
+
let cancelTimer;
|
|
27
|
+
const arm = (delay) => {
|
|
28
|
+
cancelTimer?.();
|
|
29
|
+
cancelTimer = clock.after(delay, fire);
|
|
30
|
+
};
|
|
31
|
+
const fire = () => {
|
|
32
|
+
cancelTimer = undefined;
|
|
33
|
+
if (ended)
|
|
34
|
+
return;
|
|
35
|
+
if (options.inFlight() > 0) {
|
|
36
|
+
open = true;
|
|
37
|
+
arm(pollMs);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (open) {
|
|
41
|
+
open = false;
|
|
42
|
+
arm(afterMs);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
ended = true;
|
|
46
|
+
options.stop(`the host had no call for ${afterMs} ms`);
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
start() {
|
|
50
|
+
if (started || ended)
|
|
51
|
+
return;
|
|
52
|
+
started = true;
|
|
53
|
+
arm(afterMs);
|
|
54
|
+
},
|
|
55
|
+
touch() {
|
|
56
|
+
if (!started || ended)
|
|
57
|
+
return;
|
|
58
|
+
open = false;
|
|
59
|
+
arm(afterMs);
|
|
60
|
+
},
|
|
61
|
+
cancel() {
|
|
62
|
+
ended = true;
|
|
63
|
+
cancelTimer?.();
|
|
64
|
+
cancelTimer = undefined;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The timer of the option `idle` of a host, in milliseconds. */
|
|
69
|
+
export function idleTimes(idle) {
|
|
70
|
+
const afterMs = toMs(idle.after, "idle.after");
|
|
71
|
+
if (!Number.isFinite(afterMs) || afterMs <= 0)
|
|
72
|
+
throw new RangeError(`idle.after must be more than 0 ms, got ${afterMs} ms`);
|
|
73
|
+
const pollMs = idle.poll === undefined ? Math.min(IDLE_POLL_MS, afterMs) : toMs(idle.poll, "idle.poll");
|
|
74
|
+
if (!Number.isFinite(pollMs) || pollMs <= 0)
|
|
75
|
+
throw new RangeError(`idle.poll must be more than 0 ms, got ${pollMs} ms`);
|
|
76
|
+
return { afterMs, pollMs };
|
|
77
|
+
}
|
|
78
|
+
/** This function gives the interceptor that tells a timer about each call: at its start and at its end. */
|
|
79
|
+
export function idleInterceptor(timer) {
|
|
80
|
+
return async (_invocation, next) => {
|
|
81
|
+
timer.touch();
|
|
82
|
+
try {
|
|
83
|
+
return await next();
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
timer.touch();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=idle.js.map
|
package/dist/idle.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idle.js","sourceRoot":"","sources":["../src/idle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAA+C,MAAM,oBAAoB,CAAC;AAEvF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAiClC,qDAAqD;AACrD,MAAM,UAAU,SAAS,CAAC,OAAyB;IACjD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC3C,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,4FAA4F;IAC5F,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,WAAqC,CAAC;IAC1C,MAAM,GAAG,GAAG,CAAC,KAAa,EAAQ,EAAE;QAClC,WAAW,EAAE,EAAE,CAAC;QAChB,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CA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AS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACxG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,yCAAyC,MAAM,KAAK,CAAC,CAAC;IACxH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,eAAe,CAAC,KAA+B;IAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE;QACjC,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,EAAE,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
export { parseConfig, parseTopicPatterns } from "./config.js";
|
|
9
9
|
export { runServer, startServer, loadProcedureModule, type RunningServer, type ServerRunOptions } from "./run.js";
|
|
10
10
|
export { runProcedureHost, HOST_PROFILES, type ProcedureHostRunConfig, type RunningHost, type HostRunMode } from "./host.js";
|
|
11
|
+
export { IDLE_POLL_MS, type HostIdle } from "./idle.js";
|
|
11
12
|
export type { ServerConfig, TransportConfig, ServerCreateResult, ServerStartInput, ServerStartOutput, ServerStopInput, ServerStopOutput, ServerStatusInput, ServerStatusOutput, } from "./types.js";
|
|
12
13
|
export * from "./module.js";
|
|
13
|
-
export { serverStartProcedure } from "./procedures/server.start.js";
|
|
14
|
+
export { serverStartProcedure, spawnMarkServer, type MarkServerSpawn, type ServerSpawner, type SpawnedMarkServer } from "./procedures/server.start.js";
|
|
14
15
|
export { serverStopProcedure } from "./procedures/server.stop.js";
|
|
15
16
|
export { serverStatusProcedure } from "./procedures/server.status.js";
|
|
16
17
|
export { serverStartInputSchema, serverStopInputSchema, serverStatusInputSchema, ServerStartOutputSchema, ServerStopOutputSchema, ServerStatusOutputSchema, } from "./schemas.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAElH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,sBAAsB,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAElH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,KAAK,sBAAsB,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7H,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EACV,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAIpB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,10 +9,12 @@ export { parseConfig, parseTopicPatterns } from "./config.js";
|
|
|
9
9
|
export { runServer, startServer, loadProcedureModule } from "./run.js";
|
|
10
10
|
// The runner entry of the procedures host (CLI-8): the only entry that starts run()
|
|
11
11
|
export { runProcedureHost, HOST_PROFILES } from "./host.js";
|
|
12
|
+
// The idle stop of a host (CLI-27): the option `idle` of runProcedureHost()
|
|
13
|
+
export { IDLE_POLL_MS } from "./idle.js";
|
|
12
14
|
// server.start, server.stop and server.status (from @procedures/peer). The root registers
|
|
13
15
|
// nothing: import "@procedures/server/register", or give the module to createRegistry().
|
|
14
16
|
export * from "./module.js";
|
|
15
|
-
export { serverStartProcedure } from "./procedures/server.start.js";
|
|
17
|
+
export { serverStartProcedure, spawnMarkServer } from "./procedures/server.start.js";
|
|
16
18
|
export { serverStopProcedure } from "./procedures/server.stop.js";
|
|
17
19
|
export { serverStatusProcedure } from "./procedures/server.status.js";
|
|
18
20
|
export { serverStartInputSchema, serverStopInputSchema, serverStatusInputSchema, ServerStartOutputSchema, ServerStopOutputSchema, ServerStatusOutputSchema, } from "./schemas.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAA6C,MAAM,UAAU,CAAC;AAClH,oFAAoF;AACpF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAmE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAA6C,MAAM,UAAU,CAAC;AAClH,oFAAoF;AACpF,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAmE,MAAM,WAAW,CAAC;AAC7H,4EAA4E;AAC5E,OAAO,EAAE,YAAY,EAAiB,MAAM,WAAW,CAAC;AAaxD,0FAA0F;AAC1F,yFAAyF;AACzF,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAoE,MAAM,8BAA8B,CAAC;AACvJ,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,cAAc,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* The procedure came from `@procedures/peer`: it belongs to the host. The lockfiles stay in the
|
|
9
9
|
* peer package, because the peer of `mark --server` writes them.
|
|
10
10
|
*/
|
|
11
|
+
import { type ChildProcess, type SpawnOptions } from "node:child_process";
|
|
11
12
|
import { type Effects, type FsRootRules, type Procedure } from "@procedures/client";
|
|
12
13
|
import type { ServerStartInput, ServerStartOutput } from "../types.js";
|
|
13
14
|
/** The default time to wait for the readiness of the server: 15 s. */
|
|
@@ -20,6 +21,44 @@ export declare function readinessUrl(host: string, port: number): string;
|
|
|
20
21
|
* program (audit s21).
|
|
21
22
|
*/
|
|
22
23
|
export declare function findCliPath(): string;
|
|
24
|
+
/** The function that starts a process. The default is `spawn` of `node:child_process`. The tests give their own. */
|
|
25
|
+
export type ServerSpawner = (command: string, args: readonly string[], options: SpawnOptions) => ChildProcess;
|
|
26
|
+
/** The options of `spawnMarkServer()`. */
|
|
27
|
+
export interface MarkServerSpawn {
|
|
28
|
+
readonly port: number;
|
|
29
|
+
/** The address of the listener. */
|
|
30
|
+
readonly host: string;
|
|
31
|
+
/** The transport. The default is `http`. */
|
|
32
|
+
readonly transport?: "http" | "websocket" | "both" | undefined;
|
|
33
|
+
/** The idle stop of the server, in milliseconds (`--idle-timeout`, CLI-27). Without it, the server has no idle stop. */
|
|
34
|
+
readonly idleTimeoutMs?: number | undefined;
|
|
35
|
+
/** The root of the `fs.*` procedures of the server (`--fs-root`). Without it, the server has no root. */
|
|
36
|
+
readonly fsRoot?: string | undefined;
|
|
37
|
+
/** The function that starts the process. The default is `spawn`. */
|
|
38
|
+
readonly spawner?: ServerSpawner | undefined;
|
|
39
|
+
}
|
|
40
|
+
/** The process of a server that `spawnMarkServer()` started, and the command line of the process. */
|
|
41
|
+
export interface SpawnedMarkServer {
|
|
42
|
+
readonly child: ChildProcess;
|
|
43
|
+
readonly command: string;
|
|
44
|
+
readonly args: readonly string[];
|
|
45
|
+
/** The log file of the server: its standard output and its standard error. */
|
|
46
|
+
readonly logFile: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This function starts `mark --server` as a detached background process in the current folder,
|
|
50
|
+
* and gives the process at once. It does not wait for the readiness. `server.start` and the
|
|
51
|
+
* auto-warm of `mark` (CLI-27) use it.
|
|
52
|
+
*
|
|
53
|
+
* - The command line is the command that a user runs: `mark --server --port <port> --host <host>`.
|
|
54
|
+
* - The output goes to `~/.mark/server.log`. The old log moves to `server.log.1`.
|
|
55
|
+
* - The process is detached and unref'd, so the caller can exit at once.
|
|
56
|
+
* - An error of the spawn goes to the event `error` of the process, and it does not throw.
|
|
57
|
+
*
|
|
58
|
+
* This function does not use `runCommand()` or `shell.run`. They wait for the end of the process,
|
|
59
|
+
* and this process must outlive its caller. `SERVER-LAYERS.md` records the exception.
|
|
60
|
+
*/
|
|
61
|
+
export declare function spawnMarkServer(options: MarkServerSpawn): SpawnedMarkServer;
|
|
23
62
|
export declare const serverStartProcedure: Procedure<ServerStartInput, ServerStartOutput, {
|
|
24
63
|
description: string;
|
|
25
64
|
effects: Effects;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.start.d.ts","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"server.start.d.ts","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAS,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIjF,OAAO,EAAmB,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIrG,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAQvE,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,QAAS,CAAC;AA8B9C,uHAAuH;AACvH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/D;AA0FD;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CA2BpC;AAED,oHAAoH;AACpH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,KAAK,YAAY,CAAC;AAI9G,0CAA0C;AAC1C,MAAM,WAAW,eAAe;IAC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166
|
+
const defaultSpawner = (command, args, options) => spawn(command, [...args], options);
|
|
167
|
+
/**
|
|
168
|
+
* This function starts `mark --server` as a detached background process in the current folder,
|
|
169
|
+
* and gives the process at once. It does not wait for the readiness. `server.start` and the
|
|
170
|
+
* auto-warm of `mark` (CLI-27) use it.
|
|
171
|
+
*
|
|
172
|
+
* - The command line is the command that a user runs: `mark --server --port <port> --host <host>`.
|
|
173
|
+
* - The output goes to `~/.mark/server.log`. The old log moves to `server.log.1`.
|
|
174
|
+
* - The process is detached and unref'd, so the caller can exit at once.
|
|
175
|
+
* - An error of the spawn goes to the event `error` of the process, and it does not throw.
|
|
176
|
+
*
|
|
177
|
+
* This function does not use `runCommand()` or `shell.run`. They wait for the end of the process,
|
|
178
|
+
* and this process must outlive its caller. `SERVER-LAYERS.md` records the exception.
|
|
179
|
+
*/
|
|
180
|
+
export function spawnMarkServer(options) {
|
|
181
|
+
const transport = options.transport ?? "http";
|
|
182
|
+
// Rotate log file
|
|
183
|
+
rotateLog();
|
|
184
|
+
// Ensure directories exist
|
|
185
|
+
fs.mkdirSync(SERVERS_DIR, { recursive: true });
|
|
186
|
+
// Open log file for writing
|
|
187
|
+
const logFd = fs.openSync(LOG_PATH, "a");
|
|
188
|
+
// Find CLI path
|
|
189
|
+
const cliPath = findCliPath();
|
|
190
|
+
// Build arguments: the root is a global flag, before --server
|
|
191
|
+
const args = [
|
|
192
|
+
...(options.fsRoot !== undefined ? ["--fs-root", options.fsRoot] : []),
|
|
193
|
+
"--server",
|
|
194
|
+
"--port",
|
|
195
|
+
String(options.port),
|
|
196
|
+
"--host",
|
|
197
|
+
options.host,
|
|
198
|
+
];
|
|
199
|
+
if (transport !== "http") {
|
|
200
|
+
args.push("--transport", transport);
|
|
201
|
+
}
|
|
202
|
+
if (options.idleTimeoutMs !== undefined) {
|
|
203
|
+
args.push("--idle-timeout", String(options.idleTimeoutMs));
|
|
204
|
+
}
|
|
205
|
+
// Determine how to spawn
|
|
206
|
+
let spawnCmd;
|
|
207
|
+
let spawnArgs;
|
|
208
|
+
if (cliPath === "mark" || cliPath.endsWith(".bin/mark") || cliPath.endsWith(".bin\\mark")) {
|
|
209
|
+
// Use mark command directly
|
|
210
|
+
spawnCmd = cliPath;
|
|
211
|
+
spawnArgs = args;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
// Use node to run the JS file
|
|
215
|
+
spawnCmd = process.execPath;
|
|
216
|
+
spawnArgs = [cliPath, ...args];
|
|
217
|
+
}
|
|
218
|
+
// Spawn daemon process
|
|
219
|
+
let child;
|
|
220
|
+
try {
|
|
221
|
+
child = (options.spawner ?? defaultSpawner)(spawnCmd, spawnArgs, {
|
|
222
|
+
detached: true,
|
|
223
|
+
stdio: ["ignore", logFd, logFd],
|
|
224
|
+
env: { ...process.env },
|
|
225
|
+
cwd: process.cwd(),
|
|
226
|
+
// No console window on Windows (deep dive CLI-16)
|
|
227
|
+
windowsHide: true,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
fs.closeSync(logFd);
|
|
232
|
+
}
|
|
233
|
+
// A spawn that fails, for example without `mark` in PATH, emits "error". Without a listener,
|
|
234
|
+
// the event ends the process of the caller.
|
|
235
|
+
child.once("error", () => undefined);
|
|
236
|
+
// Unref so parent can exit
|
|
237
|
+
child.unref();
|
|
238
|
+
return { child, command: spawnCmd, args: spawnArgs, logFile: LOG_PATH };
|
|
239
|
+
}
|
|
166
240
|
/**
|
|
167
241
|
* The rule under a root of the files (roadmap R33, tracker item O36): a root refuses it. It starts
|
|
168
242
|
* a mark server without the root, and it writes the log and the lock files in `~/.mark`.
|
|
@@ -198,47 +272,11 @@ export const serverStartProcedure = createProcedure()
|
|
|
198
272
|
message: `Server already running on port ${port} (PID ${existing.pid})`,
|
|
199
273
|
};
|
|
200
274
|
}
|
|
201
|
-
//
|
|
202
|
-
|
|
203
|
-
// Ensure directories exist
|
|
204
|
-
fs.mkdirSync(SERVERS_DIR, { recursive: true });
|
|
205
|
-
// Open log file for writing
|
|
206
|
-
const logFd = fs.openSync(LOG_PATH, "a");
|
|
207
|
-
// Find CLI path
|
|
208
|
-
const cliPath = findCliPath();
|
|
209
|
-
// Build arguments
|
|
210
|
-
const args = ["--server", "--port", String(port), "--host", host];
|
|
211
|
-
if (transport !== "http") {
|
|
212
|
-
args.push("--transport", transport);
|
|
213
|
-
}
|
|
214
|
-
// Determine how to spawn
|
|
215
|
-
let spawnCmd;
|
|
216
|
-
let spawnArgs;
|
|
217
|
-
if (cliPath === "mark" || cliPath.endsWith(".bin/mark") || cliPath.endsWith(".bin\\mark")) {
|
|
218
|
-
// Use mark command directly
|
|
219
|
-
spawnCmd = cliPath;
|
|
220
|
-
spawnArgs = args;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
// Use node to run the JS file
|
|
224
|
-
spawnCmd = process.execPath;
|
|
225
|
-
spawnArgs = [cliPath, ...args];
|
|
226
|
-
}
|
|
227
|
-
// Spawn daemon process
|
|
228
|
-
const child = spawn(spawnCmd, spawnArgs, {
|
|
229
|
-
detached: true,
|
|
230
|
-
stdio: ["ignore", logFd, logFd],
|
|
231
|
-
env: { ...process.env },
|
|
232
|
-
cwd: process.cwd(),
|
|
233
|
-
// No console window on Windows (deep dive CLI-16)
|
|
234
|
-
windowsHide: true,
|
|
235
|
-
});
|
|
275
|
+
// The detached process of the server, with its log (CLI-27 shares this start with the auto-warm of mark)
|
|
276
|
+
const { child } = spawnMarkServer({ port, host, transport });
|
|
236
277
|
// The end of the process stops the wait. The listener of "error" also catches a spawn that
|
|
237
278
|
// fails, for example without `mark` in PATH.
|
|
238
279
|
const end = endOf(child);
|
|
239
|
-
// Unref so parent can exit
|
|
240
|
-
child.unref();
|
|
241
|
-
fs.closeSync(logFd);
|
|
242
280
|
// The wait for the readiness (CLI-9): the readiness probe, and host.info for the identity of the server
|
|
243
281
|
const result = await waitForServer({ url: readinessUrl(host, port), port, before: existing?.peerId, end, timeoutMs });
|
|
244
282
|
if ("ready" in result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.start.js","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"server.start.js","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAwC,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAkD,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAqB,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAGhF,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AAClD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;AACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACnD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAG1D,sEAAsE;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,yDAAyD;AACzD,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,sEAAsE;AACtE,MAAM,eAAe,GAAG,KAAK,CAAC;AAK9B,wHAAwH;AACxH,SAAS,KAAK,CAAC,KAAmB;IAChC,O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EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,IAAI;QACJ,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE,iCAAiC,SAAS,yBAAyB,GAAG,IAAI,SAAS,yBAAyB,QAAQ,uCAAuC;KACrK,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/server",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.42.0",
|
|
5
5
|
"description": "A standalone procedure server: load procedure packages and serve them over HTTP and WebSocket with a token and an expose list. Its procedures server.start, server.stop and server.status manage the background server of the mark CLI.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"server",
|
|
@@ -60,20 +60,20 @@
|
|
|
60
60
|
"provenance": true
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@mark1russell7/service": "^0.
|
|
64
|
-
"@procedures/client": "0.
|
|
65
|
-
"@procedures/peer": "0.
|
|
63
|
+
"@mark1russell7/service": "^0.6.0",
|
|
64
|
+
"@procedures/client": "0.42.0",
|
|
65
|
+
"@procedures/peer": "0.42.0",
|
|
66
66
|
"zod": "^4.6.5"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@mark1russell7/cue": "^1.0.0",
|
|
70
|
-
"@procedures/fs": "0.
|
|
70
|
+
"@procedures/fs": "0.42.0",
|
|
71
71
|
"@types/node": "^22.0.0",
|
|
72
72
|
"typescript": "^7.0.2",
|
|
73
73
|
"vitest": "^5.0.3"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
|
-
"@procedures/fs": "^0.
|
|
76
|
+
"@procedures/fs": "^0.42.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@procedures/fs": {
|