@yaks/process 0.0.0-stage → 0.2.36
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/LICENSE +202 -0
- package/README.md +249 -2
- package/_dist/clock.d.ts +5 -0
- package/_dist/clock.d.ts.map +1 -0
- package/_dist/command.d.ts +43 -0
- package/_dist/command.d.ts.map +1 -0
- package/_dist/comp.d.ts +49 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/env.d.ts +8 -0
- package/_dist/env.d.ts.map +1 -0
- package/_dist/graph.d.ts +3 -0
- package/_dist/graph.d.ts.map +1 -0
- package/_dist/http.d.ts +11 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/isolate.d.ts +11 -0
- package/_dist/isolate.d.ts.map +1 -0
- package/_dist/mod.d.ts +49 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/modules.d.ts +31 -0
- package/_dist/modules.d.ts.map +1 -0
- package/_dist/platform.d.ts +7 -0
- package/_dist/platform.d.ts.map +1 -0
- package/_dist/plugin.d.ts +15 -0
- package/_dist/plugin.d.ts.map +1 -0
- package/_dist/run.d.ts +219 -0
- package/_dist/run.d.ts.map +1 -0
- package/_dist/self.d.ts +32 -0
- package/_dist/self.d.ts.map +1 -0
- package/_dist/socket.d.ts +11 -0
- package/_dist/socket.d.ts.map +1 -0
- package/_dist/store.d.ts +22 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/system.d.ts +64 -0
- package/_dist/system.d.ts.map +1 -0
- package/_dist/trash.d.ts +6 -0
- package/_dist/trash.d.ts.map +1 -0
- package/_dist/views.d.ts +4 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +8 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/wind.d.ts +35 -0
- package/_dist/wind.d.ts.map +1 -0
- package/clock.js +11 -0
- package/clock.js.map +1 -0
- package/clock.ts +11 -0
- package/command.js +172 -0
- package/command.js.map +1 -0
- package/command.ts +215 -0
- package/comp.js +54 -0
- package/comp.js.map +1 -0
- package/comp.ts +123 -0
- package/deno.json +1 -0
- package/detached.js +60 -0
- package/detached.js.map +1 -0
- package/detached.ts +92 -0
- package/detached_worker.ts +22 -0
- package/env.js +13 -0
- package/env.js.map +1 -0
- package/env.ts +24 -0
- package/graph.js +7 -0
- package/graph.js.map +1 -0
- package/graph.ts +8 -0
- package/http.js +158 -0
- package/http.js.map +1 -0
- package/http.ts +184 -0
- package/isolate.js +41 -0
- package/isolate.js.map +1 -0
- package/isolate.ts +52 -0
- package/mod.js +49 -0
- package/mod.js.map +1 -0
- package/mod.ts +50 -0
- package/modules.js +41 -0
- package/modules.js.map +1 -0
- package/modules.ts +69 -0
- package/package.json +81 -4
- package/platform.js +9 -0
- package/platform.js.map +1 -0
- package/platform.ts +9 -0
- package/plugin.js +27 -0
- package/plugin.js.map +1 -0
- package/plugin.ts +28 -0
- package/run.js +899 -0
- package/run.js.map +1 -0
- package/run.ts +1139 -0
- package/self.js +93 -0
- package/self.js.map +1 -0
- package/self.ts +144 -0
- package/socket.js +38 -0
- package/socket.js.map +1 -0
- package/socket.ts +49 -0
- package/store.js +30 -0
- package/store.js.map +1 -0
- package/store.ts +50 -0
- package/system.js +161 -0
- package/system.js.map +1 -0
- package/system.ts +216 -0
- package/testing.ts +39 -0
- package/tidy.ts +28 -0
- package/trash.js +117 -0
- package/trash.js.map +1 -0
- package/trash.ts +117 -0
- package/views.js +28 -0
- package/views.js.map +1 -0
- package/views.ts +30 -0
- package/vocab.js +16 -0
- package/vocab.js.map +1 -0
- package/vocab.json +154 -0
- package/vocab.ts +18 -0
- package/wind.js +88 -0
- package/wind.js.map +1 -0
- package/wind.ts +114 -0
package/_dist/mod.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yaks/process — a running program as an entity, so whatever needs one can
|
|
3
|
+
* point at it instead of keeping a pid of its own.
|
|
4
|
+
*
|
|
5
|
+
* - `service{command, cwd, restart, attempts}` — a program that should run,
|
|
6
|
+
* stored on the same entity its process lands on. The supervisor acts on
|
|
7
|
+
* this component, and a `stop` component beside it means the program is no
|
|
8
|
+
* longer wanted.
|
|
9
|
+
* - `process{pid, command, cwd}` — a program running on this machine;
|
|
10
|
+
* `command` and `cwd` are present exactly when we launched it.
|
|
11
|
+
* - `exit{code}` — it is over, and how. Absent means running.
|
|
12
|
+
* - output stays in the run's stdout and stderr files, never the graph:
|
|
13
|
+
* {@link tail} reads their last lines, {@link clean} removes them, and
|
|
14
|
+
* {@link sweep} removes every run's that ended long enough ago.
|
|
15
|
+
*
|
|
16
|
+
* The program doing the launching is one too: {@link started} and
|
|
17
|
+
* {@link ended} return the components a process writes about itself on the way
|
|
18
|
+
* in and the way out (./self.ts). That is the entity the server signs its
|
|
19
|
+
* writes with, and the one a start-up effect handler fires on.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { launch, store, supervise, tail, watch } from '@yaks/process'
|
|
23
|
+
*
|
|
24
|
+
* // let processes = store(graph)
|
|
25
|
+
* // let run = await launch(processes, { command: 'sh', args: ['-c', 'echo hi'] })
|
|
26
|
+
* // await run.done // 0
|
|
27
|
+
* // await tail(run.eid, 40) // ['hi']
|
|
28
|
+
* // await watch(processes) // at start-up: pick the unfinished ones back up
|
|
29
|
+
* // let pass = supervise(processes) // then drive it from your own timer
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* Four entry points over one loop: {@link launch} starts a process detached
|
|
33
|
+
* (a wrapper in a session of its own, beyond the host's service manager, a
|
|
34
|
+
* pidfile, a stdout file and a stderr file), {@link adopt} tracks one nobody
|
|
35
|
+
* here started, {@link watch} adopts every row with no `exit` again at
|
|
36
|
+
* start-up and records an exit code for the ones already gone, and
|
|
37
|
+
* {@link supervise} makes the machine match the `service` rows — start, start
|
|
38
|
+
* again with a bounded backoff, stop. The server can restart without taking
|
|
39
|
+
* any of those processes with it, which is the only reason the launcher is
|
|
40
|
+
* shaped the way it is, and exactly one supervisor sits above it (see
|
|
41
|
+
* ./run.ts).
|
|
42
|
+
*
|
|
43
|
+
* @module
|
|
44
|
+
*/ export * from "./comp.js";
|
|
45
|
+
export * from "./self.js";
|
|
46
|
+
export * from "./store.js";
|
|
47
|
+
export * from "./plugin.js";
|
|
48
|
+
export * from "./run.js";
|
|
49
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CC,GAED,0BAAyB;AACzB,0BAAyB;AACzB,2BAA0B;AAC1B,4BAA2B;AAC3B,yBAAwB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** A module graph, as `deno info --json` says one. */ export type Info = {
|
|
2
|
+
modules: {
|
|
3
|
+
specifier: string;
|
|
4
|
+
local?: string;
|
|
5
|
+
kind?: string;
|
|
6
|
+
mediaType?: string;
|
|
7
|
+
npmPackage?: string;
|
|
8
|
+
dependencies?: {
|
|
9
|
+
specifier?: string;
|
|
10
|
+
code?: {
|
|
11
|
+
specifier?: string;
|
|
12
|
+
};
|
|
13
|
+
type?: {
|
|
14
|
+
specifier?: string;
|
|
15
|
+
};
|
|
16
|
+
isDynamic?: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
}[];
|
|
19
|
+
redirects: Record<string, string>;
|
|
20
|
+
npmPackages?: Record<string, {
|
|
21
|
+
name: string;
|
|
22
|
+
dependencies: string[];
|
|
23
|
+
localPath: string;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
/** The module graph reached from `roots` (URLs) in the tree at `cwd`, a
|
|
27
|
+
* dynamic import of a literal specifier included, or undefined when deno
|
|
28
|
+
* cannot say. Deno resolves it by the tree's lock, and writes what it
|
|
29
|
+
* resolved anew (a module's `/// <reference types>`) to a copy, so the tree
|
|
30
|
+
* is never written. */ export declare let modules: (roots: string[], cwd?: string) => Promise<Info | undefined>;
|
|
31
|
+
//# sourceMappingURL=modules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.d.ts","sources":["../modules.ts"],"names":[],"mappings":"AAOA,oDAAoD,GACpD,YAAY;EACV;IACE,WAAW,MAAM;IACjB,QAAQ,MAAM;IACd,OAAO,MAAM;IACb,YAAY,MAAM;IAClB,aAAa,MAAM;IACnB;MACE,YAAY,MAAM;MAClB;QAAS,YAAY,MAAM;;MAC3B;QAAS,YAAY,MAAM;;MAC3B,YAAY,OAAO;;;EAGvB,WAAW,OAAO,MAAM,EAAE,MAAM;EAChC,cAAc,OAAO,MAAM;IACzB,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,WAAW,MAAM;;;AAYrB;;;;qBAIqB,GACrB,OAAO,YAAI,UACT,OAAO,MAAM,IACb,MAAK,MAAM,KACV,QAAQ,OAAO,SAAS,EAsB1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sources":["../platform.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,eAAc;AAElC,OAAO,YAAI,QAA+D;AAC1E,OAAO,YAAI;WAET;WACA;EACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plugin } from "@yaks/graph";
|
|
2
|
+
/**
|
|
3
|
+
* The process plugin: `process{pid, command, cwd}` and `exit{code}`.
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { graph } from '@yaks/graph'
|
|
7
|
+
* import { ram } from '@yaks/ram'
|
|
8
|
+
* import { loadVocab } from '@yaks/vocab'
|
|
9
|
+
* import { processDoc, processes } from '@yaks/process'
|
|
10
|
+
*
|
|
11
|
+
* let vocab = loadVocab([processDoc])
|
|
12
|
+
* let g = graph({ storage: ram(vocab), vocab, plugins: [processes()] })
|
|
13
|
+
* ```
|
|
14
|
+
*/ export declare let processes: () => Plugin;
|
|
15
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AAQA,cAAc,MAAM,2BAAgC;AAGpD;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,iBAAgB,OAGzB"}
|
package/_dist/run.d.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { Bundle } from "@yaks/graph";
|
|
2
|
+
import type { Store } from "./store.js";
|
|
3
|
+
/** What to run. */ export type Spec = {
|
|
4
|
+
/** the program */ command: string;
|
|
5
|
+
/** its arguments */ args?: string[];
|
|
6
|
+
/** where to run it (default the supervisor's own working directory) */ cwd?: string;
|
|
7
|
+
/** its whole environment — the child inherits nothing else */ env?: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
/** How the supervisor works, all optional. */ export type Opts = {
|
|
10
|
+
/** where the pidfiles and output files live (default `$PROCESS_DIR`, else
|
|
11
|
+
* `$TASKS_HOME/processes`, else `~/.tasks/processes`) */ dir?: string;
|
|
12
|
+
/** how long the wrapper has to write its pidfile before the child is treated
|
|
13
|
+
* as having never started (ms, default 10_000) */ birth?: number;
|
|
14
|
+
/** how often the pid and the output files are read (ms, default 1000) —
|
|
15
|
+
* every pass probes the pid, and noticing an exit within a second is
|
|
16
|
+
* plenty */ poll?: number;
|
|
17
|
+
/** mint the process entity's eid (default a uuid) */ mint?: () => string;
|
|
18
|
+
/** write the process row on this entity instead of a fresh one — what a
|
|
19
|
+
* supervisor passes so the attempt is recorded on the service row that
|
|
20
|
+
* wanted it. The previous attempt's `exit` is deleted by the same
|
|
21
|
+
* transaction, so nothing ever reads a fresh pid beside a stale exit code. */ eid?: string;
|
|
22
|
+
/** which machine's launcher to use (default this one's, `system.build.os`);
|
|
23
|
+
* the macOS one runs anywhere perl does, which is how Linux tests it */ os?: string;
|
|
24
|
+
/** whether a pid is running (default: `kill -0`) */ running?: (pid: number) => Promise<boolean>;
|
|
25
|
+
/** when this machine last started (ms since the epoch, default from its
|
|
26
|
+
* uptime): a run launched before then went with the restart */ booted?: () => number;
|
|
27
|
+
/** Stop retrying a failed exit write when the supervisor is shutting down. */ signal?: AbortSignal;
|
|
28
|
+
/** Where to report a disk-full graph write while the observation waits. */ report?: (error: unknown, context?: {
|
|
29
|
+
tags?: Record<string, string>;
|
|
30
|
+
}) => unknown;
|
|
31
|
+
};
|
|
32
|
+
/** What a caller holds of a tracked process. */ export type Run = {
|
|
33
|
+
/** Elapsed wall-clock milliseconds, including time before adoption when known. */ elapsed: () => number;
|
|
34
|
+
/** the process entity */ eid: string;
|
|
35
|
+
/** its pid — 0 when the wrapper never reported one */ pid: number;
|
|
36
|
+
/** the exit code, once it has been recorded; null when it was not
|
|
37
|
+
* observed */ done: Promise<number | null>;
|
|
38
|
+
};
|
|
39
|
+
/** How an adopted process is described, when the adopter knows more than a
|
|
40
|
+
* pid. */ export type Adoption = Opts & {
|
|
41
|
+
/** the command line, if the adopter knows it */ command?: string | null;
|
|
42
|
+
/** where it runs, if the adopter knows it */ cwd?: string | null;
|
|
43
|
+
/** the exit code, read by whoever did launch it (the fleet's session
|
|
44
|
+
* launcher keeps an exit-code file of its own) */ code?: () => number | null;
|
|
45
|
+
};
|
|
46
|
+
/** Where this supervisor keeps its files. */ export declare let dirOf: (o?: Opts, env?: (name: string) => string | undefined) => string;
|
|
47
|
+
/**
|
|
48
|
+
* The files one run keeps, named after the entity it is recorded on: its
|
|
49
|
+
* stdout and stderr files, the pidfile the wrapper writes its pid to, the
|
|
50
|
+
* file it writes the exit code to, and the file holding when it started.
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { paths } from '@yaks/process'
|
|
54
|
+
*
|
|
55
|
+
* // paths('7f3…').out // the stdout file to read
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* A caller that reads the output itself — @yaks/spawn imports a provider's
|
|
59
|
+
* JSON-lines stdout as transcript entries — needs the name of the file this
|
|
60
|
+
* package writes, and this package should state that layout rather than leave
|
|
61
|
+
* callers to assume it.
|
|
62
|
+
*/ export declare let paths: (eid: string, o?: Opts) => Record<'out' | 'err' | 'pid' | 'code' | 'started', string>;
|
|
63
|
+
export declare let literal: (arg: string) => string;
|
|
64
|
+
/** Whether a pid runs on this computer, asked with signal 0. */ export declare let runs: (pid: number) => Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Send a signal to a tracked run: to its process group where we launched it —
|
|
67
|
+
* the wrapper leads that group, so the child and anything the child started
|
|
68
|
+
* get the signal too — and to the bare pid where we only adopted it.
|
|
69
|
+
*
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { signal } from '@yaks/process'
|
|
72
|
+
*
|
|
73
|
+
* // await signal(run.eid, run.pid, 'TERM')
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* Nothing waits here: the exit code is written by the code watching the pid,
|
|
77
|
+
* in this case as in every other.
|
|
78
|
+
*/ export declare let signal: (eid: string, pid: number, sig: string, o?: Opts) => Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Trash a finished run's files: its output, and the supervisor's own.
|
|
81
|
+
*
|
|
82
|
+
* Whoever reads the output cleans once it is done with it, and nothing else
|
|
83
|
+
* does: a service's output files are its log, appended to across attempts.
|
|
84
|
+
*/ export declare let clean: (eid: string, o?: Opts) => Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Clean every run in the directory that ended more than `age` ms ago, by its
|
|
87
|
+
* exit-code file's time: what a reader that never cleaned leaves behind, such
|
|
88
|
+
* as a call nobody waited on or an answer lost to a crash. Requires a launch
|
|
89
|
+
* marker and a complete exit code. With a store, preserves sessions, services
|
|
90
|
+
* and processes whose exit has not been recorded. Answers how many.
|
|
91
|
+
*
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { sweep } from '@yaks/process'
|
|
94
|
+
*
|
|
95
|
+
* // await sweep(24 * 60 * 60 * 1000) // every run that ended a day ago
|
|
96
|
+
* ```
|
|
97
|
+
*/ export declare let sweep: (age: number, o?: Opts, processes?: Pick<Store, 'get'>) => Promise<number>;
|
|
98
|
+
/**
|
|
99
|
+
* The last `n` lines a run printed: its stdout's, then its stderr's. Read from
|
|
100
|
+
* the run's files, so it answers whoever asks for as long as they are kept.
|
|
101
|
+
*
|
|
102
|
+
* ```ts
|
|
103
|
+
* import { tail } from '@yaks/process'
|
|
104
|
+
*
|
|
105
|
+
* // await tail(run.eid, 40) // ['hi']
|
|
106
|
+
* ```
|
|
107
|
+
*/ export declare let tail: (eid: string, n: number, o?: Opts) => Promise<string[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Start a process, write its row, and record how it ended. What it prints
|
|
110
|
+
* stays in its files, for {@link tail} to read.
|
|
111
|
+
*
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { launch, store } from '@yaks/process'
|
|
114
|
+
*
|
|
115
|
+
* // let run = await launch(store(graph), { command: 'sh', args: ['-c', 'echo hi'] })
|
|
116
|
+
* // await run.done // 0
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* Resolves once the pid is known, or once the wrapper has run out of time to
|
|
120
|
+
* report one; `done` resolves when the exit code has been written.
|
|
121
|
+
*/ export declare let launch: (store: Store, spec: Spec, o?: Opts) => Promise<Run>;
|
|
122
|
+
/**
|
|
123
|
+
* Track a process nobody here launched. A pid is all it takes — `command` and
|
|
124
|
+
* `cwd` are recorded only when the caller happens to know them.
|
|
125
|
+
*
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { adopt, store } from '@yaks/process'
|
|
128
|
+
*
|
|
129
|
+
* // let run = await adopt(store(graph), 4242)
|
|
130
|
+
* ```
|
|
131
|
+
*/ export declare let adopt: (store: Store, pid: number, o?: Adoption) => Promise<Run>;
|
|
132
|
+
/**
|
|
133
|
+
* The start-up pass: pick every process that has not exited back up. One that
|
|
134
|
+
* is still alive is watched again; one that is already gone has its exit
|
|
135
|
+
* recorded now — with the code its wrapper wrote when we launched it. When
|
|
136
|
+
* nothing observed the code, the exit component has no code property and the
|
|
137
|
+
* returned run’s `done` resolves to `null`. One launched before the machine
|
|
138
|
+
* last restarted went with it: its exit says `reason: 'reboot'`.
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { store, watch } from '@yaks/process'
|
|
142
|
+
*
|
|
143
|
+
* // let runs = await watch(store(graph))
|
|
144
|
+
* ```
|
|
145
|
+
*/ export declare let watch: (store: Store, o?: Opts) => Promise<Run[]>;
|
|
146
|
+
/**
|
|
147
|
+
* The processes whose row says they are running on this machine and whose pid
|
|
148
|
+
* is gone: a run that ended without writing its own `exit` — killed, crashed,
|
|
149
|
+
* or the machine restarted under it. A run this package launched is left out,
|
|
150
|
+
* since its wrapper writes the ending and {@link watch} records it with the
|
|
151
|
+
* code, and so is `me`, the process asking.
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* import { selfEid, store, vanished } from '@yaks/process'
|
|
155
|
+
*
|
|
156
|
+
* // let dead = await vanished(store(graph), { me: selfEid() })
|
|
157
|
+
* ```
|
|
158
|
+
*/ export declare let vanished: (store: Store, o?: Asking) => Promise<Bundle[]>;
|
|
159
|
+
/** Who is asking after the dead. */ export type Asking = Opts & {
|
|
160
|
+
/** the process asking, never counted among them */ me?: string;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Whether a process is over, so nothing it held is held any more: its row
|
|
164
|
+
* records an `exit`, or it is among the {@link vanished}. A Worker thread is a
|
|
165
|
+
* row of its own in the pid it runs in (./self.ts), and that pid outlives it;
|
|
166
|
+
* the `exit` the process that ended it writes is what says it is over. What a
|
|
167
|
+
* process contending for something another holds asks (@yaks/effects `take`).
|
|
168
|
+
* `me`, the process asking, is never over to itself.
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* import { gone, selfEid, store } from '@yaks/process'
|
|
172
|
+
*
|
|
173
|
+
* // if (await gone(store(graph), holder, { me: selfEid() })) …
|
|
174
|
+
* ```
|
|
175
|
+
*/ export declare let gone: (store: Store, eid: string, o?: Asking) => Promise<boolean>;
|
|
176
|
+
/** How supervision behaves, in addition to how a process is watched. */ export type Care = Opts & {
|
|
177
|
+
/** the first backoff step (ms, default 1000): the nth respawn waits
|
|
178
|
+
* `min(step * 2 ** (n - 1), ceiling)` from the attempt it follows */ step?: number;
|
|
179
|
+
/** the longest a backoff ever waits (ms, default 60_000) — and the age at
|
|
180
|
+
* which a run stops counting as part of a crash loop, so the count of
|
|
181
|
+
* attempts starts over */ ceiling?: number;
|
|
182
|
+
/** how long a stopped process has after SIGTERM before SIGKILL follows (ms,
|
|
183
|
+
* default 10_000) */ grace?: number;
|
|
184
|
+
/** commands this supervisor must not run, in addition to its own program,
|
|
185
|
+
* which is always refused (see the header) */ refuse?: (command: string) => boolean;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Keep the wanted programs running. What is wanted is a `service` row; this is
|
|
189
|
+
* the pass that makes the machine match it, returned as a function for the
|
|
190
|
+
* caller's own timer to drive (the fleet's `tick()` in src/doing.ts).
|
|
191
|
+
*
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { store, supervise } from '@yaks/process'
|
|
194
|
+
*
|
|
195
|
+
* // let pass = supervise(store(graph))
|
|
196
|
+
* // await pass() // start what is missing, restart what exited, stop what stopped
|
|
197
|
+
* ```
|
|
198
|
+
*
|
|
199
|
+
* One pass, four decisions per row:
|
|
200
|
+
*
|
|
201
|
+
* - a `stop` component beside the service → SIGTERM the process group, then
|
|
202
|
+
* SIGKILL after the grace period, and never start it again. The row stays,
|
|
203
|
+
* so the fact that the program was wanted is recorded as over rather than
|
|
204
|
+
* deleted.
|
|
205
|
+
* - no `process` component at all → launch it.
|
|
206
|
+
* - an `exit` on the process → launch it again if `restart` calls for it,
|
|
207
|
+
* after a backoff that grows with `attempts` and stops at `ceiling`.
|
|
208
|
+
* - the service row deleted → shut the process down too, since nobody wants it
|
|
209
|
+
* any more.
|
|
210
|
+
*
|
|
211
|
+
* A process with no `exit` belongs to the code watching it, not to this pass:
|
|
212
|
+
* `launch`'s own follow loop and `watch` at start-up are what record an exit
|
|
213
|
+
* code, so there is exactly one writer of that component and this pass never
|
|
214
|
+
* infers one.
|
|
215
|
+
*
|
|
216
|
+
* The pass returns the runs it started, so a caller that wants to wait for one
|
|
217
|
+
* — a test, mostly — has the handle.
|
|
218
|
+
*/ export declare let supervise: (store: Store, o?: Care) => () => Promise<Run[]>;
|
|
219
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sources":["../run.ts"],"names":[],"mappings":"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"}
|
package/_dist/self.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Bundle, Eid } from "@yaks/graph";
|
|
2
|
+
import { type Runtime } from "./comp.js";
|
|
3
|
+
/** This process, as an entity — minted once, the same for every graph it
|
|
4
|
+
* opens. */ export declare let selfEid: () => Eid;
|
|
5
|
+
/** Run as `eid`: the name the process starting this Worker thread gave it, so
|
|
6
|
+
* that process can speak of the thread after it is gone. Called before
|
|
7
|
+
* anything asks {@link selfEid}; a thread already named otherwise refuses. */ export declare let become: (eid: Eid) => void;
|
|
8
|
+
/** What a run records about itself where the runtime cannot tell it (a test
|
|
9
|
+
* standing in for a process, a caller naming its children its own way). */ export type SelfOpts = {
|
|
10
|
+
/** the process id (default this one's) */ pid?: number;
|
|
11
|
+
/** the command line, argv joined by spaces (default this one's) */ command?: string;
|
|
12
|
+
/** where it runs (default this one's) */ cwd?: string;
|
|
13
|
+
/** the roles it serves where it opened a graph (@yaks/cli `compose`) */ roles?: string[];
|
|
14
|
+
};
|
|
15
|
+
/** What this process runs on: the runtime, its version and the operating
|
|
16
|
+
* system. */ export declare let runtime: () => Runtime;
|
|
17
|
+
/**
|
|
18
|
+
* The bundle a process writes when it starts: itself, running, and what it
|
|
19
|
+
* runs on.
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { started } from '@yaks/process'
|
|
23
|
+
*
|
|
24
|
+
* // await graph.apply([started()])
|
|
25
|
+
* ```
|
|
26
|
+
*/ export declare let started: (o?: SelfOpts) => Bundle;
|
|
27
|
+
/**
|
|
28
|
+
* The bundle it writes at the end. A code it does not know is left out rather
|
|
29
|
+
* than guessed — an `exit` with nothing in it still records that the run is
|
|
30
|
+
* over, which is the fact anything reading the row is after.
|
|
31
|
+
*/ export declare let ended: (code?: number | null) => Bundle;
|
|
32
|
+
//# sourceMappingURL=self.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self.d.ts","sources":["../self.ts"],"names":[],"mappings":"AAqCA,cAAc,MAAM,EAAE,GAAG,2BAAgC;AACzD,SAAiC,KAAK,OAAO,oBAAmB;AAIhE;UACU,GACV,OAAO,YAAI,eAAc,IAA0C;AAEnE;;4EAE4E,GAC5E,OAAO,YAAI,SAAU,KAAK,QAAM,IAAI,CAGnC;AAED;yEACyE,GACzE,YAAY;EACV,wCAAwC,GACxC,MAAM,MAAM;EACZ,iEAAiE,GACjE,UAAU,MAAM;EAChB,uCAAuC,GACvC,MAAM,MAAM;EACZ,sEAAsE,GACtE,QAAQ,MAAM;;AAuChB;WACW,GACX,OAAO,YAAI,eAAc,QAIvB;AAEF;;;;;;;;;CASC,GACD,OAAO,YAAI,UAAW,IAAG,aAAgB,OAYxC;AAED;;;;CAIC,GACD,OAAO,YAAI,QAAS,OAAO,MAAM,GAAG,IAAI,KAAG,OAGzC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Connection = {
|
|
2
|
+
read: (buffer: Uint8Array) => Promise<number | null>;
|
|
3
|
+
write: (bytes: Uint8Array) => Promise<number>;
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare let isConnectionRefused: (error: unknown) => boolean;
|
|
7
|
+
/** Connect to an operating-system socket; protocols stay with the caller. */ export declare let connect: (options: {
|
|
8
|
+
transport: 'unix';
|
|
9
|
+
path: string;
|
|
10
|
+
}) => Promise<Connection>;
|
|
11
|
+
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sources":["../socket.ts"],"names":[],"mappings":"AAIA,YAAY;EACV,OAAO,QAAQ,eAAe,QAAQ,MAAM,GAAG,IAAI;EACnD,QAAQ,OAAO,eAAe,QAAQ,MAAM;EAC5C,aAAa,IAAI;;AAGnB,OAAO,YAAI,sBAAuB,OAAO,OAAO,KAAG,OAAO,CAGzD;AAED,2EAA2E,GAC3E,OAAO,YAAI,UACT;EAAW,WAAW;EAAQ,MAAM,MAAM;MACzC,QAAQ,YA8BV"}
|
package/_dist/store.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Bundle, Graph } from "@yaks/graph";
|
|
2
|
+
import { type Built } from "@yaks/query";
|
|
3
|
+
/** Where a supervisor's rows live. */ export type Store = {
|
|
4
|
+
/** write these bundles in one transaction → the bundles as written */ apply: (bundles: Bundle[]) => Bundle[] | Promise<Bundle[]>;
|
|
5
|
+
/** the rows these eids name, whole; an eid nothing stands for is left out */ get: (eids: string[]) => Bundle[] | Promise<Bundle[]>;
|
|
6
|
+
/** every process that has not exited, as whole bundles */ running: () => Bundle[] | Promise<Bundle[]>;
|
|
7
|
+
/** every service row, whole — its `process`, `exit` and `stop` components
|
|
8
|
+
* come back in the same bundle, because they are on the same entity */ services: () => Bundle[] | Promise<Bundle[]>;
|
|
9
|
+
};
|
|
10
|
+
/** The query {@link store} runs: every process with no `exit` yet, whole. */ export declare let RUNNING: Built;
|
|
11
|
+
/** The query {@link store} runs for what is wanted: every service row. */ export declare let SERVICES: Built;
|
|
12
|
+
/**
|
|
13
|
+
* A @yaks/graph as this package's store — every read is an ordinary one, so
|
|
14
|
+
* nothing here needs privileged access.
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { store } from '@yaks/process'
|
|
18
|
+
*
|
|
19
|
+
* // let processes = store(graph)
|
|
20
|
+
* ```
|
|
21
|
+
*/ export declare let store: (graph: Pick<Graph, 'read' | 'apply' | 'get'>) => Store;
|
|
22
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sources":["../store.ts"],"names":[],"mappings":"AAWA,cAAc,MAAM,EAAE,KAAK,2BAAgC;AAC3D,SAAS,KAAK,KAAK,2BAAsC;AAGzD,oCAAoC,GACpC,YAAY;EACV,oEAAoE,GACpE,QAAQ,SAAS,aAAa,WAAW,QAAQ;EACjD,2EAA2E,GAC3E,MAAM,MAAM,MAAM,OAAO,WAAW,QAAQ;EAC5C,wDAAwD,GACxD,eAAe,WAAW,QAAQ;EAClC;uEACqE,GACrE,gBAAgB,WAAW,QAAQ;;AAGrC,2EAA2E,GAC3E,OAAO,YAAI,SAAS,MAAoC;AAExD,wEAAwE,GACxE,OAAO,YAAI,UAAU,MAA2B;AAEhD;;;;;;;;;CASC,GACD,OAAO,YAAI,QAAS,OAAO,KAAK,OAAO,SAAS,UAAU,WAAS,MAKjE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { cpus, loadavg, release } from 'node:os';
|
|
3
|
+
import { format, inspect } from 'node:util';
|
|
4
|
+
export { type Env, env } from "./env.js";
|
|
5
|
+
export { build, os } from "./platform.js";
|
|
6
|
+
export { cpus, format, inspect, loadavg };
|
|
7
|
+
export { clearInterval, clearTimeout, setInterval, setTimeout } from 'node:timers';
|
|
8
|
+
export type Signal = NodeJS.Signals;
|
|
9
|
+
export type { ChildProcess, CommandOptions, CommandOutput, CommandStatus } from "./command.js";
|
|
10
|
+
export declare let args: string[];
|
|
11
|
+
export declare let pid: any;
|
|
12
|
+
export declare let ppid: any;
|
|
13
|
+
export declare let cwd: () => string;
|
|
14
|
+
export declare let execPath: () => string;
|
|
15
|
+
export declare let mainModule: string;
|
|
16
|
+
/** Whether `reason`, met as an unhandled rejection, is the main module's own
|
|
17
|
+
* failure (a top-level await that rejected) rather than a promise nobody
|
|
18
|
+
* held. Answers within `ms`. */ export declare let mainFailed: (reason: unknown, ms?: number) => Promise<boolean>;
|
|
19
|
+
export declare let version: {
|
|
20
|
+
};
|
|
21
|
+
export declare let runtimeName: any;
|
|
22
|
+
export declare let runtimeVersion: any;
|
|
23
|
+
export declare let osRelease: any;
|
|
24
|
+
export declare let uid: () => number | null;
|
|
25
|
+
/** When this machine last started, in milliseconds since the epoch. */ export declare let booted: () => number;
|
|
26
|
+
/** What this machine calls itself. */ export declare let hostname: () => string;
|
|
27
|
+
export declare let exit: (code?: number) => never;
|
|
28
|
+
export declare let setExitCode: (code: number) => void;
|
|
29
|
+
export declare let kill: (pid: number, signal?: Signal | number) => void;
|
|
30
|
+
/** The parent's IPC channel closing, including before this listener starts.
|
|
31
|
+
* The channel is separate from stdin and is not inherited by grandchildren. */ export declare let disconnected: (source?: {
|
|
32
|
+
connected?: boolean;
|
|
33
|
+
once: (event: 'disconnect', listener: () => void) => unknown;
|
|
34
|
+
}) => Promise<void>;
|
|
35
|
+
export declare let addSignalListener: (signal: Signal, fn: () => void) => void;
|
|
36
|
+
export declare let removeSignalListener: (signal: Signal, fn: () => void) => void;
|
|
37
|
+
export declare let cpuUsage: any;
|
|
38
|
+
export declare let memoryUsage: () => NodeJS.MemoryUsage;
|
|
39
|
+
/** Gives the memory this process freed back to the system, where it can. */ export declare let trim: () => void;
|
|
40
|
+
export declare let signalCode: (signal: Signal | null) => number;
|
|
41
|
+
export declare let unrefTimer: (timer: unknown) => void;
|
|
42
|
+
export type Input = {
|
|
43
|
+
isTerminal: () => boolean;
|
|
44
|
+
setRaw: (raw: boolean, options?: {
|
|
45
|
+
cbreak?: boolean;
|
|
46
|
+
}) => void;
|
|
47
|
+
readable: ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
48
|
+
read: (buffer: Uint8Array, signal?: AbortSignal) => Promise<number | null>;
|
|
49
|
+
readSync: (buffer: Uint8Array) => number | null;
|
|
50
|
+
};
|
|
51
|
+
export type Output = {
|
|
52
|
+
isTerminal: () => boolean;
|
|
53
|
+
writeSync: (buffer: Uint8Array) => number;
|
|
54
|
+
write: (buffer: Uint8Array) => Promise<number>;
|
|
55
|
+
writable: WritableStream<Uint8Array>;
|
|
56
|
+
};
|
|
57
|
+
export declare let stdin: Input;
|
|
58
|
+
export declare let stdout: Output;
|
|
59
|
+
export declare let stderr: Output;
|
|
60
|
+
export declare let consoleSize: () => {
|
|
61
|
+
columns: number;
|
|
62
|
+
rows: number;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sources":["../system.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,eAAc;AAClC,SAAS,IAAI,EAAoB,OAAO,EAAE,OAAO,QAAgB,UAAS;AAC1E,SAAS,MAAM,EAAE,OAAO,QAAQ,YAAW;AAK3C,SAAS,KAAK,GAAG,EAAE,GAAG,mBAAkB;AACxC,SAAS,KAAK,EAAE,EAAE,wBAAuB;AAEzC,SAAS,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAE;AACzC,SACE,aAAa,EACb,YAAY,EACZ,WAAW,EACX,UAAU,QACL,cAAa;AACpB,YAAY,SAAS,OAAO;AAC5B,cACE,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,uBACM;AACrB,OAAO,YAAI,MAAM,MAAM,GAA0B;AACjD,OAAO,YAAI,SAAiB;AAC5B,OAAO,YAAI,UAAmB;AAC9B,OAAO,YAAI,WAAU,MAAM,CAAiB;AAC5C,OAAO,YAAI,gBAAe,MAAM,CAAoB;AAIpD,OAAO,YAAI,YAAY,MAAM,CACiC;AAU9D;;8BAE8B,GAC9B,OAAO,YAAI,aAAoB,QAAQ,OAAO,EAAE,gBAAU,QAAQ,OAAO,EASxE;AACD,OAAO,YAAI;EAAiC;AAC5C,OAAO,YAAI,iBAAqD;AAChE,OAAO,YAAI,oBAA+D;AAC1E,OAAO,YAAI,eAAmB;AAC9B,OAAO,YAAI,WAAU,MAAM,GAAG,IAAI,CAA8B;AAChE,qEAAqE,GACrE,OAAO,YAAI,cAAa,MAAM,CAAgC;AAC9D,oCAAoC,GACpC,OAAO,YAAI,gBAAe,MAAM,CAAU;AAC1C,OAAO,YAAI,OAAQ,OAAO,MAAM,KAAG,KAAK,CAAsB;AAC9D,OAAO,YAAI,cAAe,MAAM,MAAM,KAAG,IAAI,CAE5C;AACD,OAAO,YAAI,OAAQ,KAAK,MAAM,EAAE,SAAQ,SAAS,MAAM,KAAe,IAAI,CAEzE;AACD;6EAC6E,GAC7E,OAAO,YAAI,eACT;EACE,YAAY,OAAO;EACnB,OAAO,OAAO,cAAc,gBAAgB,IAAI,KAAK,OAAO;MAE7D,QAAQ,IAAI,EAGZ;AACH,OAAO,YAAI,oBAAqB,QAAQ,QAAQ,UAAU,IAAI,KAAG,IAAI,CAEpE;AACD,OAAO,YAAI,uBAAwB,QAAQ,QAAQ,UAAU,IAAI,KAAG,IAAI,CAEvE;AACD,OAAO,YAAI,cAA2B;AACtC,OAAO,YAAI,mBAAkB,OAAO,YAAoC;AAwBxE,0EAA0E,GAC1E,OAAO,YAAI,YAAW,IAAI,CAEzB;AACD,OAAO,YAAI,aAAc,QAAQ,SAAS,IAAI,KAAG,MAAM,CACF;AACrD,OAAO,YAAI,aAAc,OAAO,OAAO,KAAG,IAAI,CAK7C;AACD,YAAY;EACV,kBAAkB,OAAO;EACzB,SAAS,KAAK,OAAO,EAAE;IAAY,SAAS,OAAO;QAAO,IAAI;EAC9D,UAAU,eAAe,WAAW;EACpC,OAAO,QAAQ,YAAY,SAAS,gBAAgB,QAAQ,MAAM,GAAG,IAAI;EACzE,WAAW,QAAQ,eAAe,MAAM,GAAG,IAAI;;AAEjD,YAAY;EACV,kBAAkB,OAAO;EACzB,YAAY,QAAQ,eAAe,MAAM;EACzC,QAAQ,QAAQ,eAAe,QAAQ,MAAM;EAC7C,UAAU,eAAe;;AAG3B,OAAO,YAAI,OAAO,MAmDjB;AAkBD,OAAO,YAAI,QAAQ,OAAkC;AACrD,OAAO,YAAI,QAAQ,OAAkC;AACrD,OAAO,YAAI;EAAoB,SAAS,MAAM;EAAE,MAAM,MAAM;EAG1D"}
|
package/_dist/trash.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Move a file or directory into private trash. Missing sources do nothing.
|
|
2
|
+
* `root` defaults to `~/.yak/trash/files`; a persistent store can keep its own
|
|
3
|
+
* trash beside its data. The returned record holds `source.json` and `data`. */ export declare let trash: (path: string, root?: string) => Promise<string | undefined>;
|
|
4
|
+
/** Restore a record, retaining a free name when its original path is taken.
|
|
5
|
+
* The answer is the restored path, so a caller can say where it went. */ export declare let restore: (record: string) => Promise<string>;
|
|
6
|
+
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sources":["../trash.ts"],"names":[],"mappings":"AA8DA;;8EAE8E,GAC9E,OAAO,YAAI,QACT,MAAM,MAAM,EACZ,OAAM,MAAM,KACX,QAAQ,MAAM,GAAG,SAAS,EAuB5B;AAED;uEACuE,GACvE,OAAO,YAAI,UAAiB,QAAQ,MAAM,KAAG,QAAQ,MAAM,EAqB1D"}
|
package/_dist/views.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Registry } from "@yaks/render";
|
|
2
|
+
/** A command's words before its first option. */ export declare let named: (command: string) => string;
|
|
3
|
+
/** `Title` for a process that knows its command. */ export declare let views: Registry;
|
|
4
|
+
//# sourceMappingURL=views.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"views.d.ts","sources":["../views.ts"],"names":[],"mappings":"AASA,SAAiB,KAAK,QAAQ,4BAAiC;AAG/D,+CAA+C,GAC/C,OAAO,YAAI,QAAS,SAAS,MAAM,KAAG,MAAM,CAI3C;AAED,kDAAkD,GAClD,OAAO,YAAI,OAAO,SAShB"}
|
package/_dist/vocab.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { VocabDoc } from "@yaks/vocab";
|
|
2
|
+
import { processDoc } from "./comp.js";
|
|
3
|
+
export { processDoc };
|
|
4
|
+
export { EXIT, PROCESS, RUNTIME, SERVICE } from "./comp.js";
|
|
5
|
+
/** What this package is: its manifest's description, the one place it is
|
|
6
|
+
* written, which a host stamps on each document here. */ export declare let description: string;
|
|
7
|
+
/** Every vocabulary document this plugin declares. */ export declare let docs: VocabDoc[];
|
|
8
|
+
//# sourceMappingURL=vocab.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAKA,cAAc,QAAQ,2BAAgC;AACtD,SAAS,UAAU,oBAAmB;AAGtC,SAAS,UAAU,GAAE;AACrB,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,oBAAmB;AAE3D;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,oDAAoD,GACpD,OAAO,YAAI,MAAM,WAAyB"}
|
package/_dist/wind.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as system from "./system.js";
|
|
2
|
+
/** What holds the process open while it winds down. */ export type Hold = {
|
|
3
|
+
/** take nothing new and finish what was started; settles once finished */ drain: () => unknown;
|
|
4
|
+
/** end what is still going, where it stands */ force?: () => unknown;
|
|
5
|
+
};
|
|
6
|
+
/** A process winding down: what holds it, and the interrupts it hears. */ export type Wind = {
|
|
7
|
+
/** hold the process open while it winds down; the function returned lets
|
|
8
|
+
* go */ hold: (h: Hold) => () => void;
|
|
9
|
+
/** an interrupt: the first drains every hold, a second forces them. `code`
|
|
10
|
+
* is what the process ends with, 128 plus a signal's number. */ interrupt: (code: number) => void;
|
|
11
|
+
/** whether an interrupt has come */ readonly draining: boolean;
|
|
12
|
+
/** settles with the code once every hold has drained, or been forced */ done: Promise<number>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A wind of its own, for a test; a process has {@link wind}.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { assertEquals } from '@std/assert'
|
|
19
|
+
* import { winding } from '@yaks/process/wind'
|
|
20
|
+
*
|
|
21
|
+
* let w = winding()
|
|
22
|
+
* let said: string[] = []
|
|
23
|
+
* w.hold({ drain: () => said.push('drain'), force: () => said.push('force') })
|
|
24
|
+
* w.interrupt(143)
|
|
25
|
+
* assertEquals([await w.done, said], [143, ['drain']])
|
|
26
|
+
* ```
|
|
27
|
+
*/ export declare let winding: () => Wind;
|
|
28
|
+
/** This process's wind. */ export declare let wind: Wind;
|
|
29
|
+
/** The signals a process winds down on, and the code each ends it with: 128
|
|
30
|
+
* plus the signal's number, as a shell reports it. Windows delivers SIGINT
|
|
31
|
+
* alone. */ export declare let SIGNALS: [system.Signal, number][];
|
|
32
|
+
/** Hear {@link SIGNALS} as interrupts of `w`. Whoever listens first listens
|
|
33
|
+
* for the process, and the function returned stops; listening again is a
|
|
34
|
+
* no-op. */ export declare let listen: (w?: Wind) => () => void;
|
|
35
|
+
//# sourceMappingURL=wind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wind.d.ts","sources":["../wind.ts"],"names":[],"mappings":"AACA,YAAY,0BAAyB;AAkBrC,qDAAqD,GACrD,YAAY;EACV,wEAAwE,GACxE,aAAa,OAAO;EACpB,6CAA6C,GAC7C,cAAc,OAAO;;AAGvB,wEAAwE,GACxE,YAAY;EACV;QACM,GACN,OAAO,GAAG,eAAe,IAAI;EAC7B;gEAC8D,GAC9D,YAAY,MAAM,MAAM,KAAK,IAAI;EACjC,kCAAkC,YACzB,UAAU,OAAO;EAC1B,sEAAsE,GACtE,MAAM,QAAQ,MAAM;;AAGtB;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,eAAc,KA8BxB;AAED,yBAAyB,GACzB,OAAO,YAAI,MAAM,KAAgB;AAEjC;;UAEU,GACV,OAAO,YAAI,UAAU,OAAO,QAAQ,MAAM,IAEc;AAMxD;;UAEU,GACV,OAAO,YAAI,SAAU,IAAG,eAAoB,IAAI,CAS/C"}
|
package/clock.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// A host clock whose pending callbacks do not keep a command alive.
|
|
2
|
+
import { clearTimeout, setTimeout } from 'node:timers';
|
|
3
|
+
export let clock = {
|
|
4
|
+
now: Date.now,
|
|
5
|
+
after: (ms, run)=>{
|
|
6
|
+
let timer = setTimeout(run, ms);
|
|
7
|
+
timer.unref();
|
|
8
|
+
return ()=>clearTimeout(timer);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=clock.js.map
|
package/clock.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sources":["./clock.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,SAAS,YAAY,EAAE,UAAU,QAAQ,cAAa;AAEtD,OAAO,IAAI,QAAQ;EACjB,KAAK,KAAK,GAAG;EACb,OAAO,CAAC,IAAY;IAClB,IAAI,QAAQ,WAAW,KAAK;IAC5B,MAAM,KAAK;IACX,OAAO,IAAM,aAAa;EAC5B;AACF,EAAC"}
|
package/clock.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// A host clock whose pending callbacks do not keep a command alive.
|
|
2
|
+
import { clearTimeout, setTimeout } from 'node:timers'
|
|
3
|
+
|
|
4
|
+
export let clock = {
|
|
5
|
+
now: Date.now,
|
|
6
|
+
after: (ms: number, run: () => void): () => void => {
|
|
7
|
+
let timer = setTimeout(run, ms)
|
|
8
|
+
timer.unref()
|
|
9
|
+
return () => clearTimeout(timer)
|
|
10
|
+
},
|
|
11
|
+
}
|