@procedures/server 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/README.md +4 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/procedures/server.start.d.ts +8 -1
- package/dist/procedures/server.start.d.ts.map +1 -1
- package/dist/procedures/server.start.js +113 -37
- package/dist/procedures/server.start.js.map +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +2 -3
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +5 -6
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/procedures/server.start.ts +126 -44
- package/src/schemas.ts +2 -5
- package/src/types.ts +5 -6
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Procedure: server.start
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This procedure starts the CLI server (`mark --server`) as a background process. Then it waits
|
|
5
|
+
* for the readiness of the server (CLI-9). It stops the wait as soon as the server is ready or the
|
|
6
|
+
* process exits. At the timeout, it gives `success: false` with the PID of the process.
|
|
4
7
|
*
|
|
5
8
|
* The procedure came from `@procedures/peer`: it belongs to the host. The lockfiles stay in the
|
|
6
9
|
* peer package, because the peer of `mark --server` writes them.
|
|
7
10
|
*/
|
|
8
11
|
import { type Effects, type FsRootRules, type Procedure } from "@procedures/client";
|
|
9
12
|
import type { ServerStartInput, ServerStartOutput } from "../types.js";
|
|
13
|
+
/** The default time to wait for the readiness of the server: 15 s. */
|
|
14
|
+
export declare const SERVER_START_TIMEOUT_MS = 15000;
|
|
15
|
+
/** The URL of the readiness probe on the listener of a server (CLI-9). An address of all interfaces gives loopback. */
|
|
16
|
+
export declare function readinessUrl(host: string, port: number): string;
|
|
10
17
|
export declare const serverStartProcedure: Procedure<ServerStartInput, ServerStartOutput, {
|
|
11
18
|
description: string;
|
|
12
19
|
effects: Effects;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.start.d.ts","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.start.d.ts","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAA+B,KAAK,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIjH,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AASvE,sEAAsE;AACtE,eAAO,MAAM,uBAAuB,QAAS,CAAC;AA8B9C,uHAAuH;AACvH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/D;AA6HD,eAAO,MAAM,oBAAoB,EAAE,SAAS,CAC1C,gBAAgB,EAChB,iBAAiB,EACjB;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CA8GtG,CAAC;AAEX,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Procedure: server.start
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This procedure starts the CLI server (`mark --server`) as a background process. Then it waits
|
|
5
|
+
* for the readiness of the server (CLI-9). It stops the wait as soon as the server is ready or the
|
|
6
|
+
* process exits. At the timeout, it gives `success: false` with the PID of the process.
|
|
4
7
|
*
|
|
5
8
|
* The procedure came from `@procedures/peer`: it belongs to the host. The lockfiles stay in the
|
|
6
9
|
* peer package, because the peer of `mark --server` writes them.
|
|
@@ -10,6 +13,7 @@ import * as fs from "node:fs";
|
|
|
10
13
|
import * as path from "node:path";
|
|
11
14
|
import * as os from "node:os";
|
|
12
15
|
import { createProcedure, zodAdapter } from "@procedures/client";
|
|
16
|
+
import { HOST_PROBE_PREFIX } from "@procedures/peer";
|
|
13
17
|
import { checkServer, readLockfileForPort } from "@procedures/peer/lockfile";
|
|
14
18
|
import { ServerStartOutputSchema, serverStartInputSchema } from "../schemas.js";
|
|
15
19
|
const MARK_DIR = path.join(os.homedir(), ".mark");
|
|
@@ -17,16 +21,94 @@ const SERVERS_DIR = path.join(MARK_DIR, "servers");
|
|
|
17
21
|
const LOG_PATH = path.join(MARK_DIR, "server.log");
|
|
18
22
|
const LOG_PREV_PATH = path.join(MARK_DIR, "server.log.1");
|
|
19
23
|
const serverStartOutputSchema = zodAdapter(ServerStartOutputSchema);
|
|
24
|
+
/** The default time to wait for the readiness of the server: 15 s. */
|
|
25
|
+
export const SERVER_START_TIMEOUT_MS = 15_000;
|
|
26
|
+
/** The time between two reads of the readiness probe. */
|
|
27
|
+
const POLL_INTERVAL_MS = 250;
|
|
28
|
+
/** The time that one read of the probe or of `host.info` can take. */
|
|
29
|
+
const READ_TIMEOUT_MS = 1_000;
|
|
30
|
+
/** This function gives a promise of the end of a process. For a process that ended before, `exitCode` gives the end. */
|
|
31
|
+
function endOf(child) {
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
34
|
+
resolve({ code: child.exitCode, signal: child.signalCode });
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
38
|
+
child.once("error", (error) => resolve({ error }));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** The text of the end of a process, for the message of a failed start. */
|
|
42
|
+
function endText(end) {
|
|
43
|
+
if ("error" in end)
|
|
44
|
+
return `did not start (${end.error.message})`;
|
|
45
|
+
if (end.signal !== null)
|
|
46
|
+
return `stopped at the signal ${end.signal}`;
|
|
47
|
+
return `exited with the code ${end.code ?? "unknown"}`;
|
|
48
|
+
}
|
|
49
|
+
/** The URL of the readiness probe on the listener of a server (CLI-9). An address of all interfaces gives loopback. */
|
|
50
|
+
export function readinessUrl(host, port) {
|
|
51
|
+
const target = host === "0.0.0.0" ? "127.0.0.1" : host === "::" ? "::1" : host;
|
|
52
|
+
const shown = target.includes(":") && !target.startsWith("[") ? `[${target}]` : target;
|
|
53
|
+
return `http://${shown}:${port}${HOST_PROBE_PREFIX}/readiness`;
|
|
54
|
+
}
|
|
20
55
|
/**
|
|
21
|
-
*
|
|
56
|
+
* The state of the readiness probe: `ready` (200), `starting` (503, or no answer yet), or `absent`
|
|
57
|
+
* (another status: the listener has no probes, for example a build of `mark` before CLI-9).
|
|
22
58
|
*/
|
|
23
|
-
function
|
|
59
|
+
async function readProbe(url) {
|
|
24
60
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
61
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(READ_TIMEOUT_MS) });
|
|
62
|
+
await response.arrayBuffer();
|
|
63
|
+
if (response.status === 200)
|
|
64
|
+
return "ready";
|
|
65
|
+
return response.status === 503 ? "starting" : "absent";
|
|
27
66
|
}
|
|
28
67
|
catch {
|
|
29
|
-
return
|
|
68
|
+
return "starting";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The lockfile of the new server, when `host.info` answers its token with its peer id. A lockfile
|
|
73
|
+
* with the peer id `before` is from before the spawn, thus it is not the lockfile of the new server.
|
|
74
|
+
*/
|
|
75
|
+
async function newServer(port, before) {
|
|
76
|
+
const lockfile = readLockfileForPort(port);
|
|
77
|
+
if (lockfile === null || lockfile.peerId === undefined || lockfile.peerId === before)
|
|
78
|
+
return undefined;
|
|
79
|
+
return (await checkServer(lockfile, READ_TIMEOUT_MS)) === "alive" ? lockfile : undefined;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* This function waits until the new server is ready, until its process ends, or until the timeout (CLI-9).
|
|
83
|
+
*
|
|
84
|
+
* - The readiness probe of the listener (`/_probes/readiness`) tells when the service is ready.
|
|
85
|
+
* - The probe has no identity: another server on the port can answer it. Thus a ready probe also
|
|
86
|
+
* needs the lockfile of the new server, and `host.info` must answer its token with its peer id.
|
|
87
|
+
* - A listener without probes (a build of `mark` before CLI-9) answers 404. Then `host.info` alone
|
|
88
|
+
* tells the readiness, because the service refuses each call until its startup ends.
|
|
89
|
+
* - The wait stops at once when the process ends.
|
|
90
|
+
*/
|
|
91
|
+
async function waitForServer(options) {
|
|
92
|
+
let ended;
|
|
93
|
+
void options.end.then((end) => (ended = end));
|
|
94
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
95
|
+
for (;;) {
|
|
96
|
+
if (ended !== undefined)
|
|
97
|
+
return { end: ended };
|
|
98
|
+
if ((await readProbe(options.url)) !== "starting") {
|
|
99
|
+
const ready = await newServer(options.port, options.before);
|
|
100
|
+
if (ready !== undefined)
|
|
101
|
+
return { ready };
|
|
102
|
+
}
|
|
103
|
+
if (ended !== undefined)
|
|
104
|
+
return { end: ended };
|
|
105
|
+
const left = deadline - Date.now();
|
|
106
|
+
if (left <= 0)
|
|
107
|
+
return { timedOut: true };
|
|
108
|
+
let timer;
|
|
109
|
+
const pause = new Promise((resolve) => (timer = setTimeout(resolve, Math.min(POLL_INTERVAL_MS, left))));
|
|
110
|
+
await Promise.race([options.end, pause]);
|
|
111
|
+
clearTimeout(timer);
|
|
30
112
|
}
|
|
31
113
|
}
|
|
32
114
|
/**
|
|
@@ -102,6 +184,7 @@ export const serverStartProcedure = createProcedure()
|
|
|
102
184
|
// See documentation/BUGS-2026-07.md (H19).
|
|
103
185
|
const host = input.host ?? "127.0.0.1";
|
|
104
186
|
const transport = input.transport ?? "http";
|
|
187
|
+
const timeoutMs = input.timeout ?? SERVER_START_TIMEOUT_MS;
|
|
105
188
|
// Check if server is already running on this port
|
|
106
189
|
const existing = readLockfileForPort(port);
|
|
107
190
|
if (existing && (await checkServer(existing)) === "alive") {
|
|
@@ -145,47 +228,40 @@ export const serverStartProcedure = createProcedure()
|
|
|
145
228
|
// No console window on Windows (deep dive CLI-16)
|
|
146
229
|
windowsHide: true,
|
|
147
230
|
});
|
|
231
|
+
// The end of the process stops the wait. The listener of "error" also catches a spawn that
|
|
232
|
+
// fails, for example without `mark` in PATH.
|
|
233
|
+
const end = endOf(child);
|
|
148
234
|
// Unref so parent can exit
|
|
149
235
|
child.unref();
|
|
150
236
|
fs.closeSync(logFd);
|
|
151
|
-
//
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
const startTime = Date.now();
|
|
155
|
-
while (Date.now() - startTime < maxWait) {
|
|
156
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
157
|
-
// Check if child died
|
|
158
|
-
if (child.pid && !isProcessAlive(child.pid)) {
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
// Check for lockfile
|
|
162
|
-
const lockfile = readLockfileForPort(port);
|
|
163
|
-
if (lockfile && (await checkServer(lockfile)) === "alive") {
|
|
164
|
-
return {
|
|
165
|
-
success: true,
|
|
166
|
-
pid: lockfile.pid,
|
|
167
|
-
port: lockfile.port,
|
|
168
|
-
endpoint: lockfile.endpoint,
|
|
169
|
-
logFile: LOG_PATH,
|
|
170
|
-
message: `Server started (PID ${lockfile.pid})`,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
// Timed out waiting for lockfile, but child may still be alive. Deprecated (CLI-9): from the
|
|
175
|
-
// next MINOR of the client group, this result is `success: false`, with the PID of the child.
|
|
176
|
-
if (child.pid && isProcessAlive(child.pid)) {
|
|
237
|
+
// The wait for the readiness (CLI-9): the readiness probe, and host.info for the identity of the server
|
|
238
|
+
const result = await waitForServer({ url: readinessUrl(host, port), port, before: existing?.peerId, end, timeoutMs });
|
|
239
|
+
if ("ready" in result) {
|
|
177
240
|
return {
|
|
178
241
|
success: true,
|
|
179
|
-
pid:
|
|
180
|
-
port,
|
|
181
|
-
endpoint:
|
|
242
|
+
pid: result.ready.pid,
|
|
243
|
+
port: result.ready.port,
|
|
244
|
+
endpoint: result.ready.endpoint,
|
|
245
|
+
logFile: LOG_PATH,
|
|
246
|
+
message: `Server started (PID ${result.ready.pid})`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
const pid = child.pid;
|
|
250
|
+
if ("end" in result) {
|
|
251
|
+
return {
|
|
252
|
+
success: false,
|
|
253
|
+
...(pid !== undefined ? { pid } : {}),
|
|
182
254
|
logFile: LOG_PATH,
|
|
183
|
-
message: `
|
|
255
|
+
message: `The server process${pid !== undefined ? ` (PID ${pid})` : ""} ${endText(result.end)} before it was ready. Check ${LOG_PATH} for details.`,
|
|
184
256
|
};
|
|
185
257
|
}
|
|
258
|
+
// The timeout: the process still starts, but the server is not ready. Thus the start failed (CLI-9).
|
|
186
259
|
return {
|
|
187
260
|
success: false,
|
|
188
|
-
|
|
261
|
+
...(pid !== undefined ? { pid } : {}),
|
|
262
|
+
port,
|
|
263
|
+
logFile: LOG_PATH,
|
|
264
|
+
message: `The server is not ready after ${timeoutMs} ms. Its process (PID ${pid ?? "unknown"}) still starts: check ${LOG_PATH}, and run 'mark server status' later.`,
|
|
189
265
|
};
|
|
190
266
|
})
|
|
191
267
|
.build();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.start.js","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"server.start.js","sourceRoot":"","sources":["../../src/procedures/server.start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE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d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAIpB,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,gBAAgB,CAOlE,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,eAAe,CAKhE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,iBAAiB,CAIpE,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAO/D,CAAC;AAEH,eAAO,MAAM,sBAAsB,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAG7D,CAAC;AAEH,eAAO,MAAM,wBAAwB,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAUjE,CAAC"}
|
package/dist/schemas.js
CHANGED
|
@@ -14,6 +14,7 @@ export const serverStartInputSchema = zodAdapter(z.object({
|
|
|
14
14
|
port: port.optional().describe("The port to listen on (default: 3000)"),
|
|
15
15
|
host: z.string().min(1).optional().describe("The host to bind to (default: 127.0.0.1)"),
|
|
16
16
|
transport: z.enum(["http", "websocket", "both"]).optional().describe("The transport (default: http)"),
|
|
17
|
+
timeout: z.number().int().min(1).max(600_000).optional().describe("The time to wait for the readiness of the server, in milliseconds (default: 15000)"),
|
|
17
18
|
}));
|
|
18
19
|
export const serverStopInputSchema = zodAdapter(z.object({
|
|
19
20
|
port: port.optional().describe("The port of the server to stop (default: all servers)"),
|
|
@@ -23,9 +24,7 @@ export const serverStatusInputSchema = zodAdapter(z.object({
|
|
|
23
24
|
port: port.optional().describe("The port of the server (default: all servers)"),
|
|
24
25
|
}));
|
|
25
26
|
export const ServerStartOutputSchema = z.looseObject({
|
|
26
|
-
success: z
|
|
27
|
-
.boolean()
|
|
28
|
-
.describe("True when the server started. Deprecated (CLI-9): at the timeout, a server that still starts gives true. From the next MINOR, it gives false."),
|
|
27
|
+
success: z.boolean().describe("True when the server is ready. A start that is not ready at the timeout gives false, with the PID (CLI-9)"),
|
|
29
28
|
pid: z.number().optional().describe("The process id of the server"),
|
|
30
29
|
port: z.number().optional().describe("The port of the server"),
|
|
31
30
|
endpoint: z.string().optional().describe("The URL of the server"),
|
package/dist/schemas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAsB,MAAM,oBAAoB,CAAC;AAUpE,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,sBAAsB,GAAoC,UAAU,CA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AAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAC7D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;CAC3D,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAkC,CAAC,CAAC,WAAW,CAAC;IACnF,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IACxD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IACnE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IAC9D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACjE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IACxE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IACtE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IAC3E,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;IACrE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;CAC3D,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -49,15 +49,14 @@ export interface ServerStartInput {
|
|
|
49
49
|
host?: string | undefined;
|
|
50
50
|
/** Transport type */
|
|
51
51
|
transport?: "http" | "websocket" | "both" | undefined;
|
|
52
|
+
/** The time to wait for the readiness of the server, in milliseconds. The default is 15000 (CLI-9). */
|
|
53
|
+
timeout?: number | undefined;
|
|
52
54
|
}
|
|
53
55
|
export interface ServerStartOutput {
|
|
54
56
|
/**
|
|
55
|
-
* True when the server
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* timeout, a server that still starts gives `true` and the message "still loading". From the next
|
|
59
|
-
* MINOR of the client group, a start that is not ready at the timeout gives `success: false`, with
|
|
60
|
-
* the PID of the process that still starts. Read the readiness probe or `mark server status` for the state.
|
|
57
|
+
* True when the server is ready: its readiness probe answers 200, and `host.info` answers the
|
|
58
|
+
* token of its lockfile (CLI-9). A start that is not ready at the timeout gives false, with the
|
|
59
|
+
* PID of the process that still starts. Before CLI-9, it gave true.
|
|
61
60
|
*/
|
|
62
61
|
success: boolean;
|
|
63
62
|
/** Process ID of server */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,8FAA8F;IAC9F,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,MAAM,CA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AAE,OAAO,GAAG,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB;IACjB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,mBAAmB;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,oBAAoB;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,qBAAqB;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
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.22.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",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@mark1russell7/service": "^0.5.8",
|
|
64
|
-
"@procedures/client": "0.
|
|
65
|
-
"@procedures/peer": "0.
|
|
64
|
+
"@procedures/client": "0.22.0",
|
|
65
|
+
"@procedures/peer": "0.22.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.22.0",
|
|
71
71
|
"@types/node": "^22.0.0",
|
|
72
72
|
"typescript": "^7.0.2",
|
|
73
73
|
"vitest": "^5.0.3"
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Procedure: server.start
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* This procedure starts the CLI server (`mark --server`) as a background process. Then it waits
|
|
5
|
+
* for the readiness of the server (CLI-9). It stops the wait as soon as the server is ready or the
|
|
6
|
+
* process exits. At the timeout, it gives `success: false` with the PID of the process.
|
|
4
7
|
*
|
|
5
8
|
* The procedure came from `@procedures/peer`: it belongs to the host. The lockfiles stay in the
|
|
6
9
|
* peer package, because the peer of `mark --server` writes them.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
12
|
+
import { spawn, type ChildProcess } from "node:child_process";
|
|
10
13
|
import * as fs from "node:fs";
|
|
11
14
|
import * as path from "node:path";
|
|
12
15
|
import * as os from "node:os";
|
|
13
16
|
import { createProcedure, zodAdapter, type Effects, type FsRootRules, type Procedure } from "@procedures/client";
|
|
14
|
-
import {
|
|
17
|
+
import { HOST_PROBE_PREFIX } from "@procedures/peer";
|
|
18
|
+
import { checkServer, readLockfileForPort, type LockfileData } from "@procedures/peer/lockfile";
|
|
15
19
|
import { ServerStartOutputSchema, serverStartInputSchema } from "../schemas.js";
|
|
16
20
|
import type { ServerStartInput, ServerStartOutput } from "../types.js";
|
|
17
21
|
|
|
@@ -22,16 +26,105 @@ const LOG_PREV_PATH = path.join(MARK_DIR, "server.log.1");
|
|
|
22
26
|
|
|
23
27
|
const serverStartOutputSchema = zodAdapter<ServerStartOutput>(ServerStartOutputSchema);
|
|
24
28
|
|
|
29
|
+
/** The default time to wait for the readiness of the server: 15 s. */
|
|
30
|
+
export const SERVER_START_TIMEOUT_MS = 15_000;
|
|
31
|
+
|
|
32
|
+
/** The time between two reads of the readiness probe. */
|
|
33
|
+
const POLL_INTERVAL_MS = 250;
|
|
34
|
+
|
|
35
|
+
/** The time that one read of the probe or of `host.info` can take. */
|
|
36
|
+
const READ_TIMEOUT_MS = 1_000;
|
|
37
|
+
|
|
38
|
+
/** The end of the process of the server: its exit code and its signal, or the error of its spawn. */
|
|
39
|
+
type ChildEnd = { readonly code: number | null; readonly signal: NodeJS.Signals | null } | { readonly error: Error };
|
|
40
|
+
|
|
41
|
+
/** This function gives a promise of the end of a process. For a process that ended before, `exitCode` gives the end. */
|
|
42
|
+
function endOf(child: ChildProcess): Promise<ChildEnd> {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
45
|
+
resolve({ code: child.exitCode, signal: child.signalCode });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
49
|
+
child.once("error", (error) => resolve({ error }));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The text of the end of a process, for the message of a failed start. */
|
|
54
|
+
function endText(end: ChildEnd): string {
|
|
55
|
+
if ("error" in end) return `did not start (${end.error.message})`;
|
|
56
|
+
if (end.signal !== null) return `stopped at the signal ${end.signal}`;
|
|
57
|
+
return `exited with the code ${end.code ?? "unknown"}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The URL of the readiness probe on the listener of a server (CLI-9). An address of all interfaces gives loopback. */
|
|
61
|
+
export function readinessUrl(host: string, port: number): string {
|
|
62
|
+
const target = host === "0.0.0.0" ? "127.0.0.1" : host === "::" ? "::1" : host;
|
|
63
|
+
const shown = target.includes(":") && !target.startsWith("[") ? `[${target}]` : target;
|
|
64
|
+
return `http://${shown}:${port}${HOST_PROBE_PREFIX}/readiness`;
|
|
65
|
+
}
|
|
25
66
|
|
|
26
67
|
/**
|
|
27
|
-
*
|
|
68
|
+
* The state of the readiness probe: `ready` (200), `starting` (503, or no answer yet), or `absent`
|
|
69
|
+
* (another status: the listener has no probes, for example a build of `mark` before CLI-9).
|
|
28
70
|
*/
|
|
29
|
-
function
|
|
71
|
+
async function readProbe(url: string): Promise<"ready" | "starting" | "absent"> {
|
|
30
72
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
73
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(READ_TIMEOUT_MS) });
|
|
74
|
+
await response.arrayBuffer();
|
|
75
|
+
if (response.status === 200) return "ready";
|
|
76
|
+
return response.status === 503 ? "starting" : "absent";
|
|
33
77
|
} catch {
|
|
34
|
-
return
|
|
78
|
+
return "starting";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The lockfile of the new server, when `host.info` answers its token with its peer id. A lockfile
|
|
84
|
+
* with the peer id `before` is from before the spawn, thus it is not the lockfile of the new server.
|
|
85
|
+
*/
|
|
86
|
+
async function newServer(port: number, before: string | undefined): Promise<LockfileData | undefined> {
|
|
87
|
+
const lockfile = readLockfileForPort(port);
|
|
88
|
+
if (lockfile === null || lockfile.peerId === undefined || lockfile.peerId === before) return undefined;
|
|
89
|
+
return (await checkServer(lockfile, READ_TIMEOUT_MS)) === "alive" ? lockfile : undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** What the wait for the server gives: the lockfile of the ready server, the end of its process, or the timeout. */
|
|
93
|
+
type WaitResult = { readonly ready: LockfileData } | { readonly end: ChildEnd } | { readonly timedOut: true };
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This function waits until the new server is ready, until its process ends, or until the timeout (CLI-9).
|
|
97
|
+
*
|
|
98
|
+
* - The readiness probe of the listener (`/_probes/readiness`) tells when the service is ready.
|
|
99
|
+
* - The probe has no identity: another server on the port can answer it. Thus a ready probe also
|
|
100
|
+
* needs the lockfile of the new server, and `host.info` must answer its token with its peer id.
|
|
101
|
+
* - A listener without probes (a build of `mark` before CLI-9) answers 404. Then `host.info` alone
|
|
102
|
+
* tells the readiness, because the service refuses each call until its startup ends.
|
|
103
|
+
* - The wait stops at once when the process ends.
|
|
104
|
+
*/
|
|
105
|
+
async function waitForServer(options: {
|
|
106
|
+
readonly url: string;
|
|
107
|
+
readonly port: number;
|
|
108
|
+
readonly before: string | undefined;
|
|
109
|
+
readonly end: Promise<ChildEnd>;
|
|
110
|
+
readonly timeoutMs: number;
|
|
111
|
+
}): Promise<WaitResult> {
|
|
112
|
+
let ended: ChildEnd | undefined;
|
|
113
|
+
void options.end.then((end) => (ended = end));
|
|
114
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
115
|
+
for (;;) {
|
|
116
|
+
if (ended !== undefined) return { end: ended };
|
|
117
|
+
if ((await readProbe(options.url)) !== "starting") {
|
|
118
|
+
const ready = await newServer(options.port, options.before);
|
|
119
|
+
if (ready !== undefined) return { ready };
|
|
120
|
+
}
|
|
121
|
+
if (ended !== undefined) return { end: ended };
|
|
122
|
+
const left = deadline - Date.now();
|
|
123
|
+
if (left <= 0) return { timedOut: true };
|
|
124
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
125
|
+
const pause = new Promise<void>((resolve) => (timer = setTimeout(resolve, Math.min(POLL_INTERVAL_MS, left))));
|
|
126
|
+
await Promise.race([options.end, pause]);
|
|
127
|
+
clearTimeout(timer);
|
|
35
128
|
}
|
|
36
129
|
}
|
|
37
130
|
|
|
@@ -117,6 +210,7 @@ export const serverStartProcedure: Procedure<
|
|
|
117
210
|
// See documentation/BUGS-2026-07.md (H19).
|
|
118
211
|
const host = input.host ?? "127.0.0.1";
|
|
119
212
|
const transport = input.transport ?? "http";
|
|
213
|
+
const timeoutMs = input.timeout ?? SERVER_START_TIMEOUT_MS;
|
|
120
214
|
|
|
121
215
|
// Check if server is already running on this port
|
|
122
216
|
const existing = readLockfileForPort(port);
|
|
@@ -168,54 +262,42 @@ export const serverStartProcedure: Procedure<
|
|
|
168
262
|
// No console window on Windows (deep dive CLI-16)
|
|
169
263
|
windowsHide: true,
|
|
170
264
|
});
|
|
265
|
+
// The end of the process stops the wait. The listener of "error" also catches a spawn that
|
|
266
|
+
// fails, for example without `mark` in PATH.
|
|
267
|
+
const end = endOf(child);
|
|
171
268
|
|
|
172
269
|
// Unref so parent can exit
|
|
173
270
|
child.unref();
|
|
174
271
|
fs.closeSync(logFd);
|
|
175
272
|
|
|
176
|
-
//
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const startTime = Date.now();
|
|
180
|
-
|
|
181
|
-
while (Date.now() - startTime < maxWait) {
|
|
182
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
183
|
-
|
|
184
|
-
// Check if child died
|
|
185
|
-
if (child.pid && !isProcessAlive(child.pid)) {
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Check for lockfile
|
|
190
|
-
const lockfile = readLockfileForPort(port);
|
|
191
|
-
if (lockfile && (await checkServer(lockfile)) === "alive") {
|
|
192
|
-
return {
|
|
193
|
-
success: true,
|
|
194
|
-
pid: lockfile.pid,
|
|
195
|
-
port: lockfile.port,
|
|
196
|
-
endpoint: lockfile.endpoint,
|
|
197
|
-
logFile: LOG_PATH,
|
|
198
|
-
message: `Server started (PID ${lockfile.pid})`,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Timed out waiting for lockfile, but child may still be alive. Deprecated (CLI-9): from the
|
|
204
|
-
// next MINOR of the client group, this result is `success: false`, with the PID of the child.
|
|
205
|
-
if (child.pid && isProcessAlive(child.pid)) {
|
|
273
|
+
// The wait for the readiness (CLI-9): the readiness probe, and host.info for the identity of the server
|
|
274
|
+
const result = await waitForServer({ url: readinessUrl(host, port), port, before: existing?.peerId, end, timeoutMs });
|
|
275
|
+
if ("ready" in result) {
|
|
206
276
|
return {
|
|
207
277
|
success: true,
|
|
208
|
-
pid:
|
|
209
|
-
port,
|
|
210
|
-
endpoint:
|
|
278
|
+
pid: result.ready.pid,
|
|
279
|
+
port: result.ready.port,
|
|
280
|
+
endpoint: result.ready.endpoint,
|
|
211
281
|
logFile: LOG_PATH,
|
|
212
|
-
message: `Server
|
|
282
|
+
message: `Server started (PID ${result.ready.pid})`,
|
|
213
283
|
};
|
|
214
284
|
}
|
|
215
|
-
|
|
285
|
+
const pid = child.pid;
|
|
286
|
+
if ("end" in result) {
|
|
287
|
+
return {
|
|
288
|
+
success: false,
|
|
289
|
+
...(pid !== undefined ? { pid } : {}),
|
|
290
|
+
logFile: LOG_PATH,
|
|
291
|
+
message: `The server process${pid !== undefined ? ` (PID ${pid})` : ""} ${endText(result.end)} before it was ready. Check ${LOG_PATH} for details.`,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
// The timeout: the process still starts, but the server is not ready. Thus the start failed (CLI-9).
|
|
216
295
|
return {
|
|
217
296
|
success: false,
|
|
218
|
-
|
|
297
|
+
...(pid !== undefined ? { pid } : {}),
|
|
298
|
+
port,
|
|
299
|
+
logFile: LOG_PATH,
|
|
300
|
+
message: `The server is not ready after ${timeoutMs} ms. Its process (PID ${pid ?? "unknown"}) still starts: check ${LOG_PATH}, and run 'mark server status' later.`,
|
|
219
301
|
};
|
|
220
302
|
})
|
|
221
303
|
.build();
|
package/src/schemas.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const serverStartInputSchema: ZodLikeSchema<ServerStartInput> = zodAdapte
|
|
|
26
26
|
port: port.optional().describe("The port to listen on (default: 3000)"),
|
|
27
27
|
host: z.string().min(1).optional().describe("The host to bind to (default: 127.0.0.1)"),
|
|
28
28
|
transport: z.enum(["http", "websocket", "both"]).optional().describe("The transport (default: http)"),
|
|
29
|
+
timeout: z.number().int().min(1).max(600_000).optional().describe("The time to wait for the readiness of the server, in milliseconds (default: 15000)"),
|
|
29
30
|
})
|
|
30
31
|
);
|
|
31
32
|
|
|
@@ -43,11 +44,7 @@ export const serverStatusInputSchema: ZodLikeSchema<ServerStatusInput> = zodAdap
|
|
|
43
44
|
);
|
|
44
45
|
|
|
45
46
|
export const ServerStartOutputSchema: z.ZodType<ServerStartOutput> = z.looseObject({
|
|
46
|
-
success: z
|
|
47
|
-
.boolean()
|
|
48
|
-
.describe(
|
|
49
|
-
"True when the server started. Deprecated (CLI-9): at the timeout, a server that still starts gives true. From the next MINOR, it gives false."
|
|
50
|
-
),
|
|
47
|
+
success: z.boolean().describe("True when the server is ready. A start that is not ready at the timeout gives false, with the PID (CLI-9)"),
|
|
51
48
|
pid: z.number().optional().describe("The process id of the server"),
|
|
52
49
|
port: z.number().optional().describe("The port of the server"),
|
|
53
50
|
endpoint: z.string().optional().describe("The URL of the server"),
|
package/src/types.ts
CHANGED
|
@@ -54,16 +54,15 @@ export interface ServerStartInput {
|
|
|
54
54
|
host?: string | undefined;
|
|
55
55
|
/** Transport type */
|
|
56
56
|
transport?: "http" | "websocket" | "both" | undefined;
|
|
57
|
+
/** The time to wait for the readiness of the server, in milliseconds. The default is 15000 (CLI-9). */
|
|
58
|
+
timeout?: number | undefined;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
export interface ServerStartOutput {
|
|
60
62
|
/**
|
|
61
|
-
* True when the server
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* timeout, a server that still starts gives `true` and the message "still loading". From the next
|
|
65
|
-
* MINOR of the client group, a start that is not ready at the timeout gives `success: false`, with
|
|
66
|
-
* the PID of the process that still starts. Read the readiness probe or `mark server status` for the state.
|
|
63
|
+
* True when the server is ready: its readiness probe answers 200, and `host.info` answers the
|
|
64
|
+
* token of its lockfile (CLI-9). A start that is not ready at the timeout gives false, with the
|
|
65
|
+
* PID of the process that still starts. Before CLI-9, it gave true.
|
|
67
66
|
*/
|
|
68
67
|
success: boolean;
|
|
69
68
|
/** Process ID of server */
|