@songsid/agend 2.1.1-beta.18 → 2.1.1-beta.19
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/dist/backend/kiro.js +29 -0
- package/dist/backend/kiro.js.map +1 -1
- package/dist/fleet-manager.js +2 -2
- package/dist/fleet-manager.js.map +1 -1
- package/dist/sd-notify.d.ts +27 -0
- package/dist/sd-notify.js +33 -1
- package/dist/sd-notify.js.map +1 -1
- package/package.json +1 -1
package/dist/sd-notify.d.ts
CHANGED
|
@@ -15,5 +15,32 @@ export declare function isFleetOwner(dataDir?: string, pid?: number): boolean;
|
|
|
15
15
|
type NotifyExecutor = (file: string, args: readonly string[], options: Parameters<typeof execFileSync>[2]) => unknown;
|
|
16
16
|
/** Exported for a focused test of the exact helper environment. */
|
|
17
17
|
export declare function sendSystemdNotification(state: string, socket: string, environment: NodeJS.ProcessEnv, execute?: NotifyExecutor): void;
|
|
18
|
+
export type AsyncNotifyExecutor = (file: string, args: readonly string[], options: {
|
|
19
|
+
env: NodeJS.ProcessEnv;
|
|
20
|
+
timeout: number;
|
|
21
|
+
}, callback: (error: Error | null) => void) => unknown;
|
|
22
|
+
/** Exported so a test can drive the async path without spawning anything. */
|
|
23
|
+
export declare function sendSystemdNotificationAsync(state: string, socket: string, environment: NodeJS.ProcessEnv, execute?: AsyncNotifyExecutor): void;
|
|
24
|
+
/**
|
|
25
|
+
* Send a notification without blocking the event loop.
|
|
26
|
+
*
|
|
27
|
+
* The watchdog ping exists to prove this process is still turning its event
|
|
28
|
+
* loop. Proving it with `execFileSync` stopped the loop for as long as the fork
|
|
29
|
+
* took — up to the 5s timeout — every 30 seconds, and forking is slowest exactly
|
|
30
|
+
* when the machine is loaded, i.e. when the ping matters. A fire-and-forget spawn
|
|
31
|
+
* says the same thing about liveness (the timer fired, the call was made) without
|
|
32
|
+
* contradicting itself.
|
|
33
|
+
*
|
|
34
|
+
* Still a subprocess: Node does not expose AF_UNIX datagram sockets, so
|
|
35
|
+
* systemd-notify remains the only way to reach NOTIFY_SOCKET from here.
|
|
36
|
+
*/
|
|
18
37
|
export declare function sdNotify(state: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Blocking variant, for the one case where the process is about to exit.
|
|
40
|
+
*
|
|
41
|
+
* `STOPPING=1` has to reach systemd before the event loop stops running, and an
|
|
42
|
+
* async spawn queued on the way out may simply never be executed. Nothing else
|
|
43
|
+
* should use this.
|
|
44
|
+
*/
|
|
45
|
+
export declare function sdNotifyBlocking(state: string): void;
|
|
19
46
|
export {};
|
package/dist/sd-notify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
1
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { getAgendHome } from "./paths.js";
|
|
@@ -38,7 +38,39 @@ export function sendSystemdNotification(state, socket, environment, execute = ex
|
|
|
38
38
|
timeout: 5000,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
/** Exported so a test can drive the async path without spawning anything. */
|
|
42
|
+
export function sendSystemdNotificationAsync(state, socket, environment, execute = execFile) {
|
|
43
|
+
execute("systemd-notify", [state], { env: buildNotifyEnvironment(environment, socket), timeout: 5000 }, () => { });
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Send a notification without blocking the event loop.
|
|
47
|
+
*
|
|
48
|
+
* The watchdog ping exists to prove this process is still turning its event
|
|
49
|
+
* loop. Proving it with `execFileSync` stopped the loop for as long as the fork
|
|
50
|
+
* took — up to the 5s timeout — every 30 seconds, and forking is slowest exactly
|
|
51
|
+
* when the machine is loaded, i.e. when the ping matters. A fire-and-forget spawn
|
|
52
|
+
* says the same thing about liveness (the timer fired, the call was made) without
|
|
53
|
+
* contradicting itself.
|
|
54
|
+
*
|
|
55
|
+
* Still a subprocess: Node does not expose AF_UNIX datagram sockets, so
|
|
56
|
+
* systemd-notify remains the only way to reach NOTIFY_SOCKET from here.
|
|
57
|
+
*/
|
|
41
58
|
export function sdNotify(state) {
|
|
59
|
+
if (!notifySocket || !isFleetOwner())
|
|
60
|
+
return;
|
|
61
|
+
try {
|
|
62
|
+
sendSystemdNotificationAsync(state, notifySocket, process.env);
|
|
63
|
+
}
|
|
64
|
+
catch { /* best effort */ }
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Blocking variant, for the one case where the process is about to exit.
|
|
68
|
+
*
|
|
69
|
+
* `STOPPING=1` has to reach systemd before the event loop stops running, and an
|
|
70
|
+
* async spawn queued on the way out may simply never be executed. Nothing else
|
|
71
|
+
* should use this.
|
|
72
|
+
*/
|
|
73
|
+
export function sdNotifyBlocking(state) {
|
|
42
74
|
if (!notifySocket || !isFleetOwner())
|
|
43
75
|
return;
|
|
44
76
|
try {
|
package/dist/sd-notify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sd-notify.js","sourceRoot":"","sources":["../src/sd-notify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"sd-notify.js","sourceRoot":"","sources":["../src/sd-notify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,WAA8B;IAChE,MAAM,MAAM,GAAG,WAAW,CAAC,aAAa,CAAC;IACzC,OAAO,WAAW,CAAC,aAAa,CAAC;IACjC,OAAO,MAAM,IAAI,SAAS,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,WAA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