unitup 0.1.5 → 0.3.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/.agents/AGENTS.md +35 -0
- package/.agents/skills/multi-runtime-management/SKILL.md +80 -0
- package/.agents/skills/platform-service-adapters/SKILL.md +108 -0
- package/.agents/skills/unitup-development-and-qa/SKILL.md +88 -0
- package/.agents/skills/zero-downtime-deployment/SKILL.md +135 -0
- package/CHANGELOG.md +5 -3
- package/README.md +89 -8
- package/biome.json +0 -1
- package/docs/index.html +188 -234
- package/index.d.ts +467 -440
- package/package.json +9 -3
- package/src/cli.js +561 -103
- package/src/core/drain-manager.js +70 -0
- package/src/core/generation-manager.js +414 -0
- package/src/core/index.js +8 -0
- package/src/core/ipc.js +236 -0
- package/src/core/lock.js +133 -0
- package/src/core/process-manager.js +313 -0
- package/src/core/readiness.js +243 -0
- package/src/core/router.js +390 -0
- package/src/core/supervisor.js +222 -0
- package/src/deploy/deployment-manager.js +407 -0
- package/src/deploy/index.js +9 -0
- package/src/deploy/rollback-manager.js +186 -0
- package/src/doctor.js +123 -56
- package/src/errors.js +131 -0
- package/src/index.js +186 -59
- package/src/logs.js +148 -0
- package/src/platform/base.js +211 -0
- package/src/platform/index.js +43 -0
- package/src/platform/linux.js +155 -0
- package/src/platform/macos.js +726 -0
- package/src/platform/windows-host.js +246 -0
- package/src/platform/windows.js +498 -0
- package/src/runtimes/bun.js +1 -1
- package/src/runtimes/common.js +24 -6
- package/src/runtimes/deno.js +1 -1
- package/src/runtimes/elixir.js +1 -1
- package/src/runtimes/go.js +1 -1
- package/src/runtimes/index.js +7 -7
- package/src/runtimes/native.js +2 -4
- package/src/runtimes/node.js +1 -1
- package/src/runtimes/php.js +1 -1
- package/src/runtimes/python.js +1 -1
- package/src/runtimes/ruby.js +1 -1
- package/src/runtimes/shell.js +1 -1
- package/src/schedule.js +31 -24
- package/src/service/config.js +63 -0
- package/src/service/manager.js +233 -0
- package/src/service/normalize.js +245 -0
- package/src/systemd.js +84 -38
- package/src/unit.js +17 -19
- package/src/utils.js +112 -18
- package/tsconfig.json +1 -1
- package/types-test/index.ts +158 -0
package/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* unitup -
|
|
2
|
+
* unitup - Cross-platform native background service manager (systemd, launchd, Windows Services)
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { ChildProcess } from 'node:child_process';
|
|
5
|
+
import type { ChildProcess } from 'node:child_process';
|
|
6
|
+
import type { EventEmitter } from 'node:events';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
|
-
* Options for creating/adding a
|
|
9
|
+
* Options for creating/adding/installing a service.
|
|
9
10
|
*/
|
|
10
11
|
export interface CreateServiceOptions {
|
|
11
12
|
/**
|
|
@@ -14,6 +15,16 @@ export interface CreateServiceOptions {
|
|
|
14
15
|
*/
|
|
15
16
|
name: string;
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Optional display name (used on Windows/macOS where supported).
|
|
20
|
+
*/
|
|
21
|
+
displayName?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Optional service description.
|
|
25
|
+
*/
|
|
26
|
+
description?: string;
|
|
27
|
+
|
|
17
28
|
/**
|
|
18
29
|
* Optional group name (e.g. 'myproject').
|
|
19
30
|
* @default 'default'
|
|
@@ -26,7 +37,7 @@ export interface CreateServiceOptions {
|
|
|
26
37
|
runtime?: string;
|
|
27
38
|
|
|
28
39
|
/**
|
|
29
|
-
* Runtime-specific flags/arguments passed before script
|
|
40
|
+
* Runtime-specific flags/arguments passed before script.
|
|
30
41
|
*/
|
|
31
42
|
runtimeArgs?: string[];
|
|
32
43
|
|
|
@@ -51,20 +62,28 @@ export interface CreateServiceOptions {
|
|
|
51
62
|
nodePath?: string;
|
|
52
63
|
|
|
53
64
|
/**
|
|
54
|
-
* Key-value map of environment variables to inject
|
|
65
|
+
* Key-value map of environment variables to inject.
|
|
55
66
|
*/
|
|
56
67
|
env?: Record<string, string>;
|
|
57
68
|
|
|
58
69
|
/**
|
|
59
|
-
* Path to an environment file
|
|
70
|
+
* Path to an environment file.
|
|
60
71
|
*/
|
|
61
72
|
envFile?: string;
|
|
62
73
|
|
|
63
74
|
/**
|
|
64
|
-
*
|
|
75
|
+
* Restart policy string (e.g., 'on-failure', 'always', 'no') or object.
|
|
65
76
|
* @default 'on-failure'
|
|
66
77
|
*/
|
|
67
|
-
restart?:
|
|
78
|
+
restart?:
|
|
79
|
+
| string
|
|
80
|
+
| {
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
policy?: string;
|
|
83
|
+
delay?: number;
|
|
84
|
+
maxRetries?: number | null;
|
|
85
|
+
resetAfter?: number | null;
|
|
86
|
+
};
|
|
68
87
|
|
|
69
88
|
/**
|
|
70
89
|
* Positional arguments to pass to the script/command execution line.
|
|
@@ -84,30 +103,25 @@ export interface CreateServiceOptions {
|
|
|
84
103
|
force?: boolean;
|
|
85
104
|
|
|
86
105
|
/**
|
|
87
|
-
*
|
|
88
|
-
|
|
89
|
-
memoryHigh?: string;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Hard memory limit directive (e.g. '512M').
|
|
106
|
+
* Install as system-wide daemon (LaunchDaemons on macOS, root systemd on Linux).
|
|
107
|
+
* @default false
|
|
93
108
|
*/
|
|
94
|
-
|
|
109
|
+
system?: boolean;
|
|
95
110
|
|
|
96
111
|
/**
|
|
97
|
-
*
|
|
112
|
+
* Graceful shutdown timeout in milliseconds before force killing child.
|
|
113
|
+
* @default 10000
|
|
98
114
|
*/
|
|
99
|
-
|
|
115
|
+
shutdownTimeout?: number;
|
|
100
116
|
|
|
101
117
|
/**
|
|
102
|
-
*
|
|
118
|
+
* Custom log paths.
|
|
103
119
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
logs?: {
|
|
121
|
+
stdout?: string;
|
|
122
|
+
stderr?: string;
|
|
123
|
+
};
|
|
106
124
|
|
|
107
|
-
/**
|
|
108
|
-
* Options for setting or resetting service memory limits.
|
|
109
|
-
*/
|
|
110
|
-
export interface ServiceLimitsOptions {
|
|
111
125
|
/**
|
|
112
126
|
* Soft memory limit directive (e.g. '400M').
|
|
113
127
|
*/
|
|
@@ -124,215 +138,167 @@ export interface ServiceLimitsOptions {
|
|
|
124
138
|
memorySwapMax?: string;
|
|
125
139
|
|
|
126
140
|
/**
|
|
127
|
-
*
|
|
128
|
-
* @default false
|
|
141
|
+
* Default memory limit fallback or request marker (defaults to '1G').
|
|
129
142
|
*/
|
|
130
|
-
|
|
143
|
+
defaultMemory?: string | boolean;
|
|
131
144
|
}
|
|
132
145
|
|
|
133
|
-
|
|
134
|
-
* Options for retrieving journalctl log output.
|
|
135
|
-
*/
|
|
136
|
-
export interface LogOptions {
|
|
137
|
-
/**
|
|
138
|
-
* Live streaming follow mode (-f).
|
|
139
|
-
* @default false
|
|
140
|
-
*/
|
|
141
|
-
follow?: boolean;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Number of journal log lines to return (-n).
|
|
145
|
-
* @default 100
|
|
146
|
-
*/
|
|
147
|
-
lines?: number;
|
|
146
|
+
export interface InstallServiceOptions extends CreateServiceOptions {}
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
export interface NormalizedServiceConfig {
|
|
149
|
+
name: string;
|
|
150
|
+
displayName: string;
|
|
151
|
+
description: string;
|
|
152
|
+
runtime: string;
|
|
153
|
+
command: string;
|
|
154
|
+
args: string[];
|
|
155
|
+
script?: string;
|
|
156
|
+
cwd: string;
|
|
157
|
+
env: Record<string, string>;
|
|
158
|
+
envFile?: string;
|
|
159
|
+
autostart: boolean;
|
|
160
|
+
restart: {
|
|
161
|
+
enabled: boolean;
|
|
162
|
+
policy: string;
|
|
163
|
+
delay: number;
|
|
164
|
+
maxRetries?: number | null;
|
|
165
|
+
resetAfter?: number | null;
|
|
166
|
+
};
|
|
167
|
+
logs: {
|
|
168
|
+
stdout: string;
|
|
169
|
+
stderr: string;
|
|
170
|
+
};
|
|
171
|
+
group: string;
|
|
172
|
+
system: boolean;
|
|
173
|
+
shutdownTimeout: number;
|
|
174
|
+
resources: {
|
|
175
|
+
memoryHigh?: string;
|
|
176
|
+
memoryMax?: string;
|
|
177
|
+
memorySwapMax?: string;
|
|
178
|
+
};
|
|
179
|
+
raw?: Record<string, unknown>;
|
|
180
|
+
}
|
|
154
181
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
182
|
+
export interface PlatformCapabilities {
|
|
183
|
+
serviceManager: 'systemd' | 'launchd' | 'windows' | 'none';
|
|
184
|
+
supports: {
|
|
185
|
+
install: boolean;
|
|
186
|
+
uninstall: boolean;
|
|
187
|
+
start: boolean;
|
|
188
|
+
stop: boolean;
|
|
189
|
+
restart: boolean;
|
|
190
|
+
enable: boolean;
|
|
191
|
+
disable: boolean;
|
|
192
|
+
status: boolean;
|
|
193
|
+
logs: boolean;
|
|
194
|
+
restartPolicy: boolean;
|
|
195
|
+
userServices: boolean;
|
|
196
|
+
systemServices: boolean;
|
|
197
|
+
memoryLimits: boolean;
|
|
198
|
+
schedule: boolean;
|
|
199
|
+
};
|
|
159
200
|
}
|
|
160
201
|
|
|
161
|
-
/**
|
|
162
|
-
* Parsed compact service status summary.
|
|
163
|
-
*/
|
|
164
202
|
export interface ServiceStatus {
|
|
165
|
-
/**
|
|
166
|
-
* Clean service name (e.g. 'api').
|
|
167
|
-
*/
|
|
168
203
|
name: string;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
* Full systemd unit filename (e.g. 'unitup-api.service').
|
|
172
|
-
*/
|
|
173
|
-
unitFile: string;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Status overview ('running', 'stopped', 'failed', 'exited', etc.).
|
|
177
|
-
*/
|
|
204
|
+
installed: boolean;
|
|
205
|
+
state: 'running' | 'stopped' | 'starting' | 'stopping' | 'failed' | 'scheduled' | 'unknown' | string;
|
|
178
206
|
status: string;
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Raw ActiveState string from systemctl show.
|
|
182
|
-
*/
|
|
183
|
-
activeState: string;
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Raw SubState string from systemctl show.
|
|
187
|
-
*/
|
|
188
|
-
subState: string;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Main Process ID (PID) of the service, or '-' if stopped.
|
|
192
|
-
*/
|
|
207
|
+
enabled: boolean | string;
|
|
193
208
|
pid: string;
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Total number of restarts recorded by systemd.
|
|
197
|
-
*/
|
|
198
|
-
restarts: string;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Relative formatted uptime/started string (e.g. '12 minutes ago').
|
|
202
|
-
*/
|
|
209
|
+
restarts: string | number;
|
|
203
210
|
started: string;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Raw timestamp from systemctl show.
|
|
207
|
-
*/
|
|
208
|
-
startedRaw?: string;
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Executable command path.
|
|
212
|
-
*/
|
|
211
|
+
startedRaw?: string | null;
|
|
213
212
|
command: string;
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Command arguments string.
|
|
217
|
-
*/
|
|
218
213
|
arguments: string;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Array of command arguments.
|
|
222
|
-
*/
|
|
223
214
|
args: string[];
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Path to target script parsed from unit file.
|
|
227
|
-
*/
|
|
228
|
-
script: string;
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Working directory parsed from unit file.
|
|
232
|
-
*/
|
|
215
|
+
script?: string;
|
|
233
216
|
cwd: string;
|
|
217
|
+
unitFile?: string;
|
|
218
|
+
unitPath?: string;
|
|
219
|
+
platform: 'linux' | 'darwin' | 'win32' | string;
|
|
220
|
+
manager: 'systemd' | 'launchd' | 'windows' | string;
|
|
221
|
+
memory?: string;
|
|
222
|
+
memoryPeak?: string;
|
|
223
|
+
memoryHigh?: string;
|
|
224
|
+
memoryMax?: string;
|
|
225
|
+
memorySwapMax?: string;
|
|
226
|
+
details?: Record<string, unknown>;
|
|
234
227
|
}
|
|
235
228
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
/**
|
|
251
|
-
* Group name.
|
|
252
|
-
*/
|
|
253
|
-
group: string;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Status overview ('running', 'stopped', 'failed', etc.).
|
|
257
|
-
*/
|
|
258
|
-
status: string;
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Enabled status ('yes' or 'no').
|
|
262
|
-
*/
|
|
263
|
-
enabled: string;
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Main PID or '-'.
|
|
267
|
-
*/
|
|
268
|
-
pid: string;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Command summary (e.g. 'node server.js' or 'python3 worker.py').
|
|
272
|
-
*/
|
|
273
|
-
command: string;
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Formatted uptime string.
|
|
277
|
-
*/
|
|
278
|
-
uptime: string;
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Restart count.
|
|
282
|
-
*/
|
|
283
|
-
restarts: string;
|
|
229
|
+
export interface LogOptions {
|
|
230
|
+
follow?: boolean;
|
|
231
|
+
lines?: number;
|
|
232
|
+
cat?: boolean;
|
|
233
|
+
output?: string;
|
|
234
|
+
since?: string;
|
|
235
|
+
until?: string;
|
|
236
|
+
priority?: string;
|
|
237
|
+
grep?: string;
|
|
238
|
+
boot?: boolean;
|
|
239
|
+
json?: boolean;
|
|
240
|
+
diskUsage?: boolean;
|
|
241
|
+
system?: boolean;
|
|
284
242
|
}
|
|
285
243
|
|
|
286
|
-
/**
|
|
287
|
-
* App metadata saved in ~/.config/unitup/apps/<name>.json.
|
|
288
|
-
*/
|
|
289
244
|
export interface AppMetadata {
|
|
290
|
-
name: string;
|
|
291
|
-
unit: string;
|
|
292
|
-
runtime?: string;
|
|
293
|
-
command?: string;
|
|
294
|
-
args?: string[];
|
|
295
|
-
group: string;
|
|
296
|
-
script: string;
|
|
297
|
-
cwd: string;
|
|
298
|
-
node: string;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Detailed application inspection summary (unitup inspect).
|
|
303
|
-
*/
|
|
304
|
-
export interface InspectInfo {
|
|
305
245
|
name: string;
|
|
306
246
|
runtime: string;
|
|
307
|
-
unit: string;
|
|
308
|
-
unitPath: string;
|
|
309
|
-
group: string;
|
|
310
|
-
status: string;
|
|
311
|
-
activeState: string;
|
|
312
|
-
subState: string;
|
|
313
247
|
command: string;
|
|
314
|
-
arguments: string;
|
|
315
248
|
args: string[];
|
|
316
249
|
cwd: string;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
250
|
+
group?: string;
|
|
251
|
+
script?: string;
|
|
252
|
+
pid?: string;
|
|
253
|
+
restarts?: string;
|
|
254
|
+
started?: string;
|
|
255
|
+
logs?: {
|
|
256
|
+
stdout?: string;
|
|
257
|
+
stderr?: string;
|
|
258
|
+
};
|
|
259
|
+
resources?: {
|
|
260
|
+
memoryHigh?: string;
|
|
261
|
+
memoryMax?: string;
|
|
262
|
+
memorySwapMax?: string;
|
|
263
|
+
};
|
|
264
|
+
[key: string]: unknown;
|
|
265
|
+
}
|
|
320
266
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
267
|
+
export interface DoctorInfo {
|
|
268
|
+
platform: string;
|
|
269
|
+
systemdAvailable: boolean;
|
|
270
|
+
systemctlAvailable: boolean;
|
|
271
|
+
linux: boolean;
|
|
272
|
+
systemdRunning: boolean;
|
|
273
|
+
userSystemdAvailable: boolean;
|
|
274
|
+
lingering: boolean;
|
|
275
|
+
nodePath: string | null;
|
|
276
|
+
nodeVersion: string | null;
|
|
277
|
+
nodeValid: boolean;
|
|
278
|
+
username: string;
|
|
279
|
+
unitDir: string;
|
|
280
|
+
unitDirWritable: boolean;
|
|
281
|
+
[key: string]: unknown;
|
|
282
|
+
}
|
|
326
283
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
284
|
+
export interface ListServiceItem {
|
|
285
|
+
name: string;
|
|
286
|
+
status: string;
|
|
287
|
+
enabled?: boolean | string;
|
|
288
|
+
pid?: string;
|
|
289
|
+
command?: string;
|
|
290
|
+
[key: string]: unknown;
|
|
330
291
|
}
|
|
331
292
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
293
|
+
export interface NodeDiagnostics {
|
|
294
|
+
found: boolean;
|
|
295
|
+
path: string | null;
|
|
296
|
+
version: string | null;
|
|
297
|
+
valid: boolean;
|
|
298
|
+
error?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface ServiceFailure {
|
|
336
302
|
name: string;
|
|
337
303
|
group: string;
|
|
338
304
|
status: string;
|
|
@@ -341,137 +307,178 @@ export interface FailureItem {
|
|
|
341
307
|
uptime: string;
|
|
342
308
|
}
|
|
343
309
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
export interface NodeDiagnostics {
|
|
348
|
-
found: boolean;
|
|
349
|
-
executable: boolean;
|
|
350
|
-
execPath: string;
|
|
351
|
-
whichPath: string;
|
|
352
|
-
version: string;
|
|
353
|
-
inPath: boolean;
|
|
354
|
-
error: string | null;
|
|
355
|
-
solution: string | null;
|
|
310
|
+
// Error Classes
|
|
311
|
+
export class UnitupError extends Error {
|
|
312
|
+
code: string;
|
|
356
313
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
* Diagnostic report object from unitup doctor.
|
|
360
|
-
*/
|
|
361
|
-
export interface DoctorInfo {
|
|
362
|
-
linux: boolean;
|
|
363
|
-
systemctl: boolean;
|
|
364
|
-
systemdRunning: boolean;
|
|
365
|
-
userSystemdAvailable: boolean;
|
|
366
|
-
cgroupV2?: boolean;
|
|
367
|
-
memoryController?: boolean;
|
|
368
|
-
memoryMaxSupported?: boolean;
|
|
369
|
-
memorySwapMaxSupported?: boolean;
|
|
370
|
-
nodeDiag: NodeDiagnostics;
|
|
371
|
-
nodePath: string;
|
|
372
|
-
nodeVersion: string;
|
|
373
|
-
runtimes: Record<string, string | null>;
|
|
374
|
-
unitDir: string;
|
|
375
|
-
unitDirWritable: boolean;
|
|
376
|
-
lingering: boolean;
|
|
377
|
-
username: string;
|
|
314
|
+
export class UnsupportedPlatformError extends UnitupError {
|
|
315
|
+
platform: string;
|
|
378
316
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
317
|
+
export class ServiceNotFoundError extends UnitupError {
|
|
318
|
+
serviceName: string;
|
|
319
|
+
}
|
|
320
|
+
export class ServiceAlreadyExistsError extends UnitupError {
|
|
321
|
+
serviceName: string;
|
|
322
|
+
}
|
|
323
|
+
export class PermissionRequiredError extends UnitupError {
|
|
324
|
+
action?: string;
|
|
325
|
+
}
|
|
326
|
+
export class ServiceStartError extends UnitupError {
|
|
327
|
+
serviceName: string;
|
|
328
|
+
reason?: string;
|
|
329
|
+
}
|
|
330
|
+
export class ServiceStopError extends UnitupError {
|
|
331
|
+
serviceName: string;
|
|
332
|
+
reason?: string;
|
|
333
|
+
}
|
|
334
|
+
export class InvalidServiceConfigError extends UnitupError {
|
|
335
|
+
field?: string;
|
|
336
|
+
}
|
|
337
|
+
export class ExecutableNotFoundError extends UnitupError {
|
|
338
|
+
executable: string;
|
|
339
|
+
}
|
|
340
|
+
export class ReadinessTimeoutError extends Error {
|
|
341
|
+
generation: GenerationRecord;
|
|
342
|
+
}
|
|
343
|
+
export class ProcessStartupError extends Error {
|
|
344
|
+
generation: GenerationRecord;
|
|
345
|
+
}
|
|
346
|
+
export class PortMismatchError extends Error {
|
|
347
|
+
generation: GenerationRecord;
|
|
348
|
+
detectedPort: number;
|
|
349
|
+
}
|
|
350
|
+
export class DeploymentLockError extends Error {
|
|
351
|
+
service: string;
|
|
352
|
+
lockedPid?: number;
|
|
386
353
|
}
|
|
387
354
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
355
|
+
// Adapters
|
|
356
|
+
export abstract class ServiceAdapter {
|
|
357
|
+
constructor(options?: Record<string, unknown>);
|
|
358
|
+
readonly name: string;
|
|
359
|
+
readonly capabilities: PlatformCapabilities;
|
|
360
|
+
abstract generateService(config: NormalizedServiceConfig): string | Record<string, unknown>;
|
|
361
|
+
abstract install(
|
|
362
|
+
config: NormalizedServiceConfig,
|
|
363
|
+
options?: Record<string, unknown>
|
|
364
|
+
): Promise<{ name: string; unitPath?: string; serviceName?: string }>;
|
|
365
|
+
abstract uninstall(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
366
|
+
abstract start(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
367
|
+
abstract stop(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
368
|
+
abstract restart(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
369
|
+
abstract enable(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
370
|
+
abstract disable(name: string, options?: Record<string, unknown>): Promise<boolean>;
|
|
371
|
+
abstract status(name: string, options?: Record<string, unknown>): Promise<ServiceStatus>;
|
|
372
|
+
abstract inspect(name: string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
373
|
+
abstract logs(name: string, options?: LogOptions): Promise<string | EventEmitter | ChildProcess>;
|
|
374
|
+
abstract list(options?: { group?: string }): Promise<Array<Record<string, unknown>>>;
|
|
375
|
+
abstract isInstalled(name: string, options?: Record<string, unknown>): Promise<boolean> | boolean;
|
|
376
|
+
abstract failures(options?: Record<string, unknown>): Promise<ServiceFailure[]>;
|
|
400
377
|
}
|
|
401
378
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
export
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
379
|
+
export class LinuxAdapter extends ServiceAdapter {}
|
|
380
|
+
export class MacOSAdapter extends ServiceAdapter {}
|
|
381
|
+
export class WindowsAdapter extends ServiceAdapter {}
|
|
382
|
+
export class WindowsServiceHost {
|
|
383
|
+
constructor(config?: Record<string, unknown>);
|
|
384
|
+
start(): void;
|
|
385
|
+
stop(timeout?: number): Promise<void>;
|
|
386
|
+
}
|
|
410
387
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
388
|
+
export class ServiceManager {
|
|
389
|
+
constructor(opts?: { platform?: string; adapter?: ServiceAdapter });
|
|
390
|
+
readonly capabilities: PlatformCapabilities;
|
|
391
|
+
generate(rawOpts?: CreateServiceOptions): Promise<string | Record<string, unknown>>;
|
|
392
|
+
install(rawOpts: CreateServiceOptions): Promise<{ name: string; unitPath?: string; serviceName?: string }>;
|
|
393
|
+
uninstall(name: string, options?: { force?: boolean; system?: boolean }): Promise<boolean>;
|
|
394
|
+
start(name: string, options?: { enable?: boolean; system?: boolean }): Promise<boolean>;
|
|
395
|
+
stop(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
396
|
+
restart(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
397
|
+
enable(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
398
|
+
disable(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
399
|
+
status(name: string, options?: { system?: boolean }): Promise<ServiceStatus>;
|
|
400
|
+
inspect(name: string, options?: { system?: boolean }): Promise<Record<string, unknown>>;
|
|
401
|
+
logs(name: string, options?: LogOptions): Promise<string | EventEmitter | ChildProcess>;
|
|
402
|
+
list(options?: { group?: string }): Promise<Array<Record<string, unknown>>>;
|
|
403
|
+
failures(options?: Record<string, unknown>): Promise<ServiceFailure[]>;
|
|
404
|
+
isInstalled(name: string, options?: Record<string, unknown>): Promise<boolean> | boolean;
|
|
405
|
+
}
|
|
414
406
|
|
|
415
|
-
export
|
|
416
|
-
|
|
407
|
+
export const defaultManager: ServiceManager;
|
|
408
|
+
|
|
409
|
+
// Unified API functions
|
|
410
|
+
export function install(options: CreateServiceOptions): Promise<{ name: string; unitPath?: string }>;
|
|
411
|
+
export function uninstall(name: string, options?: { force?: boolean; system?: boolean }): Promise<boolean>;
|
|
412
|
+
export function start(name: string, options?: { enable?: boolean; system?: boolean }): Promise<boolean>;
|
|
413
|
+
export function stop(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
414
|
+
export function restart(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
415
|
+
export function status(name: string, options?: { system?: boolean }): Promise<ServiceStatus>;
|
|
416
|
+
export function list(options?: { group?: string }): Promise<Array<Record<string, unknown>>>;
|
|
417
|
+
export function inspect(name: string, options?: { system?: boolean }): Promise<Record<string, unknown>>;
|
|
418
|
+
export function logs(name: string, options?: LogOptions): Promise<string | EventEmitter | ChildProcess>;
|
|
419
|
+
export function enable(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
420
|
+
export function disable(name: string, options?: { system?: boolean }): Promise<boolean>;
|
|
421
|
+
export function platform(targetPlatform?: string): PlatformCapabilities;
|
|
422
|
+
|
|
423
|
+
export function getAdapter(platform?: string, options?: Record<string, unknown>): ServiceAdapter;
|
|
424
|
+
export function getPlatformCapabilities(platform?: string): PlatformCapabilities;
|
|
425
|
+
export function normalizeServiceConfig(rawOpts?: Record<string, unknown>): Promise<NormalizedServiceConfig>;
|
|
426
|
+
export function resolveExecutable(binaryName: string, opts?: { cwd?: string; pathEnv?: string }): string | null;
|
|
427
|
+
export function readServiceLogs(filePaths: string | string[], options?: LogOptions): Promise<string | EventEmitter>;
|
|
428
|
+
|
|
429
|
+
// Backward-compatible API
|
|
430
|
+
export function createService(options: CreateServiceOptions): Promise<{ name: string; unitPath: string }>;
|
|
431
|
+
export function addService(options: CreateServiceOptions): Promise<{ name: string; unitPath: string }>;
|
|
417
432
|
export function startService(name: string, enable?: boolean): Promise<boolean>;
|
|
418
433
|
export function stopService(name: string): Promise<boolean>;
|
|
419
434
|
export function restartService(name: string): Promise<boolean>;
|
|
420
|
-
export function removeService(name: string, options?: { force?: boolean }
|
|
435
|
+
export function removeService(name: string, options?: boolean | { force?: boolean }): Promise<boolean>;
|
|
421
436
|
export function getServiceStatus(name: string): Promise<ServiceStatus>;
|
|
422
437
|
export function getServiceStatusRaw(name: string): Promise<string>;
|
|
423
|
-
export function listServices(
|
|
424
|
-
export function inspectService(name: string): Promise<
|
|
425
|
-
export function getServiceFailures(): Promise<
|
|
438
|
+
export function listServices(filterOpts?: { group?: string }): Promise<ListServiceItem[]>;
|
|
439
|
+
export function inspectService(name: string): Promise<Record<string, unknown>>;
|
|
440
|
+
export function getServiceFailures(): Promise<ServiceFailure[]>;
|
|
426
441
|
export function getServicesByGroup(groupName: string): Promise<string[]>;
|
|
427
|
-
export function setServiceLimits(name: string, options?:
|
|
428
|
-
export function getServiceMemoryUsage(name: string): Promise<
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
group: string;
|
|
445
|
-
type: string;
|
|
446
|
-
status: string;
|
|
447
|
-
pid: string;
|
|
448
|
-
memory: string;
|
|
449
|
-
memoryPeak: string;
|
|
450
|
-
memoryMax: string;
|
|
451
|
-
memoryHigh: string;
|
|
452
|
-
memoryBytes: number;
|
|
453
|
-
}>;
|
|
454
|
-
totalBytes: number;
|
|
455
|
-
totalMemory: string;
|
|
456
|
-
runningCount: number;
|
|
457
|
-
}>;
|
|
458
|
-
export function executeJournalctlMaintenance(action: string, options?: Record<string, unknown>): Promise<string>;
|
|
459
|
-
export function getServiceLogs(name: string, options?: LogOptions): Promise<string | ChildProcess>;
|
|
460
|
-
|
|
461
|
-
// Validation & Formatting Helpers
|
|
462
|
-
export function validateMemorySize(val: string | number, paramName?: string): string;
|
|
442
|
+
export function setServiceLimits(name: string, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
443
|
+
export function getServiceMemoryUsage(name: string): Promise<Record<string, unknown>>;
|
|
444
|
+
export function getAllServicesMemoryUsage(opts?: { group?: string }): Promise<Record<string, unknown>>;
|
|
445
|
+
export function executeJournalctlMaintenance(action: string, opts?: Record<string, unknown>): Promise<string>;
|
|
446
|
+
export function getServiceLogs(name: string, opts?: LogOptions): Promise<string | ChildProcess>;
|
|
447
|
+
export function runJournalctlLogs(name: string, opts?: LogOptions): Promise<string | ChildProcess>;
|
|
448
|
+
|
|
449
|
+
// Runtimes & Helpers
|
|
450
|
+
export function detectRuntime(filepath: string, opts?: Record<string, unknown>): string;
|
|
451
|
+
export function resolveRuntimeConfig(
|
|
452
|
+
opts?: Record<string, unknown>
|
|
453
|
+
): Promise<{ command: string; args: string[]; runtime: string; version: string }>;
|
|
454
|
+
export function sanitizeServiceName(name: string): string;
|
|
455
|
+
export function formatTable(
|
|
456
|
+
data: Array<Record<string, unknown>>,
|
|
457
|
+
columns: Array<{ key: string; label: string }>
|
|
458
|
+
): string;
|
|
463
459
|
export function formatMemoryBytes(bytes: number | string): string;
|
|
460
|
+
export function formatDuration(ms: number): string;
|
|
461
|
+
export function validateMemorySize(val: string | number, paramName?: string): string;
|
|
462
|
+
export function validateDuration(val: string | number, paramName?: string): string;
|
|
464
463
|
|
|
465
|
-
//
|
|
466
|
-
export function
|
|
467
|
-
export function
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
464
|
+
// Config helpers
|
|
465
|
+
export function findProjectConfig(dirPath?: string): string | null;
|
|
466
|
+
export function readProjectConfig(filePathOrDir?: string): Record<string, unknown> | null;
|
|
467
|
+
export function saveProjectConfig(dirPathOrFile?: string, config?: Record<string, unknown>): string;
|
|
468
|
+
export function readAppMetadata(name: string): AppMetadata | null;
|
|
469
|
+
export function getAppMetadataPath(name: string): string;
|
|
470
|
+
export function getAppsDir(): string;
|
|
471
|
+
export function getUnitupDir(): string;
|
|
472
|
+
export function readGlobalConfig(): Record<string, unknown>;
|
|
473
|
+
export function saveGlobalConfig(config: Record<string, unknown>): Record<string, unknown>;
|
|
474
|
+
export function getConfigFilepath(): string;
|
|
475
|
+
export function resolveEffectiveMemoryLimits(opts?: Record<string, unknown>): {
|
|
476
|
+
memoryHigh?: string;
|
|
477
|
+
memoryMax?: string;
|
|
478
|
+
memorySwapMax?: string;
|
|
479
|
+
};
|
|
473
480
|
|
|
474
|
-
//
|
|
481
|
+
// Doctor & Diagnostics
|
|
475
482
|
export function isSystemdAvailable(): Promise<boolean>;
|
|
476
483
|
export function isSystemctlAvailable(): Promise<boolean>;
|
|
477
484
|
export function isLinux(): boolean;
|
|
@@ -481,147 +488,167 @@ export function checkUserLinger(): Promise<boolean>;
|
|
|
481
488
|
export function checkNodeDiagnostics(customNodePath?: string): Promise<NodeDiagnostics>;
|
|
482
489
|
export function findNodeExecutable(customPath?: string): Promise<string | null>;
|
|
483
490
|
export function getDoctorInfo(): Promise<DoctorInfo>;
|
|
491
|
+
export function runDoctor(): Promise<DoctorInfo>;
|
|
484
492
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
memoryMax?: string;
|
|
499
|
-
memorySwapMax?: string;
|
|
500
|
-
};
|
|
501
|
-
memoryHigh?: string;
|
|
502
|
-
memoryMax?: string;
|
|
503
|
-
memorySwapMax?: string;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
export function findProjectConfig(dirPath?: string): string | null;
|
|
507
|
-
export function readProjectConfig(filePathOrDir?: string): ProjectConfig | null;
|
|
508
|
-
export function saveProjectConfig(dirPathOrFile?: string, config?: ProjectConfig): string;
|
|
493
|
+
// Testing runner overrides
|
|
494
|
+
export type CommandRunnerFn = (
|
|
495
|
+
cmd: string,
|
|
496
|
+
args: string[],
|
|
497
|
+
opts?: Record<string, unknown>
|
|
498
|
+
) => Promise<{ stdout: string; stderr: string; code: number }>;
|
|
499
|
+
export function setCommandRunner(runner: CommandRunnerFn): void;
|
|
500
|
+
export function resetCommandRunner(): void;
|
|
501
|
+
export function runCommand(
|
|
502
|
+
cmd: string,
|
|
503
|
+
args: string[],
|
|
504
|
+
opts?: Record<string, unknown>
|
|
505
|
+
): Promise<{ stdout: string; stderr: string; code: number }>;
|
|
509
506
|
|
|
510
|
-
//
|
|
507
|
+
// Unit / Plist helpers
|
|
511
508
|
export function getUserUnitDir(): string;
|
|
512
509
|
export function getUnitPath(name: string): string;
|
|
513
510
|
export function unitFileExists(name: string): boolean;
|
|
514
|
-
export function parseUnitContent(content: string):
|
|
515
|
-
export function sanitizeServiceName(name: string): string;
|
|
511
|
+
export function parseUnitContent(content: string): Record<string, unknown>;
|
|
516
512
|
export function getUnitFilename(name: string): string;
|
|
513
|
+
export function getTimerFilename(name: string): string;
|
|
517
514
|
export function getServiceNameFromUnit(unitFilename: string): string;
|
|
518
|
-
export function
|
|
519
|
-
export function
|
|
520
|
-
export function
|
|
521
|
-
export function
|
|
515
|
+
export function generateTimerContent(opts: Record<string, unknown>): string;
|
|
516
|
+
export function generateScheduleServiceContent(opts: Record<string, unknown>): string;
|
|
517
|
+
export function getTimerPath(name: string): string;
|
|
518
|
+
export function timerFileExists(name: string): boolean;
|
|
522
519
|
|
|
523
|
-
//
|
|
524
|
-
export function
|
|
525
|
-
export function
|
|
520
|
+
// Schedules
|
|
521
|
+
export function createSchedule(options: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
522
|
+
export function listSchedules(group?: string): Promise<Array<Record<string, unknown>>>;
|
|
523
|
+
export function getScheduleStatus(name: string): Promise<Record<string, unknown>>;
|
|
524
|
+
export function runSchedule(name: string): Promise<boolean>;
|
|
525
|
+
export function enableSchedule(name: string): Promise<boolean>;
|
|
526
|
+
export function disableSchedule(name: string): Promise<boolean>;
|
|
527
|
+
export function removeSchedule(name: string, options?: { force?: boolean }): Promise<boolean>;
|
|
528
|
+
export function validateCalendar(expression: string): Promise<{ valid: boolean; error?: string; warning?: string }>;
|
|
529
|
+
export function readScheduleMetadata(name: string): Record<string, unknown> | null;
|
|
530
|
+
export function getScheduleMetadataPath(name: string): string;
|
|
531
|
+
export function getSchedulesDir(): string;
|
|
526
532
|
|
|
527
|
-
//
|
|
528
|
-
|
|
529
|
-
|
|
533
|
+
// Zero-Downtime Deployment Primitives & Orchestration
|
|
534
|
+
export interface GenerationRecord {
|
|
535
|
+
id: number;
|
|
536
|
+
service: string;
|
|
537
|
+
pid: number;
|
|
538
|
+
internalPort: number;
|
|
539
|
+
status: 'starting' | 'active' | 'previous' | 'draining' | 'stopped' | 'canary' | string;
|
|
540
|
+
createdAt: string;
|
|
541
|
+
activatedAt?: string;
|
|
542
|
+
drainingAt?: string;
|
|
543
|
+
stoppedAt?: string;
|
|
544
|
+
canaryWeight?: number;
|
|
545
|
+
}
|
|
530
546
|
|
|
531
|
-
export interface
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
cwd?: string;
|
|
539
|
-
env?: Record<string, string> | string[];
|
|
540
|
-
envFile?: string;
|
|
541
|
-
group?: string;
|
|
542
|
-
memoryHigh?: string;
|
|
543
|
-
memoryMax?: string;
|
|
544
|
-
memorySwapMax?: string;
|
|
545
|
-
defaultMemory?: string | boolean;
|
|
546
|
-
every?: string;
|
|
547
|
-
calendar?: string;
|
|
548
|
-
onBoot?: string;
|
|
549
|
-
onActive?: string;
|
|
550
|
-
randomDelay?: string;
|
|
551
|
-
persistent?: boolean;
|
|
552
|
-
start?: boolean;
|
|
553
|
-
enable?: boolean;
|
|
547
|
+
export interface DeploymentResult {
|
|
548
|
+
service: string;
|
|
549
|
+
previousGeneration: number | null;
|
|
550
|
+
currentGeneration: number;
|
|
551
|
+
downtimeMs: number;
|
|
552
|
+
status: string;
|
|
553
|
+
canaryWeight?: number;
|
|
554
554
|
}
|
|
555
555
|
|
|
556
|
-
export interface
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
args: string[];
|
|
563
|
-
cwd: string;
|
|
564
|
-
schedule: {
|
|
565
|
-
every: string | null;
|
|
566
|
-
calendar: string | null;
|
|
567
|
-
onBoot: string | null;
|
|
568
|
-
onActive: string | null;
|
|
569
|
-
persistent: boolean;
|
|
570
|
-
randomDelay: string | null;
|
|
571
|
-
};
|
|
572
|
-
serviceUnit: string;
|
|
573
|
-
timerUnit: string;
|
|
556
|
+
export interface PromoteResult {
|
|
557
|
+
service: string;
|
|
558
|
+
promotedGeneration: number;
|
|
559
|
+
previousGeneration: number | null;
|
|
560
|
+
downtimeMs: number;
|
|
561
|
+
status: string;
|
|
574
562
|
}
|
|
575
563
|
|
|
576
|
-
export interface
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
nextRun: string;
|
|
581
|
-
lastRun: string;
|
|
564
|
+
export interface RollbackResult {
|
|
565
|
+
service: string;
|
|
566
|
+
rolledBackFrom: number | null;
|
|
567
|
+
activeGeneration: number;
|
|
582
568
|
status: string;
|
|
583
|
-
activeState: string;
|
|
584
|
-
subState: string;
|
|
585
|
-
unitFileState: string;
|
|
586
|
-
serviceActiveState: string;
|
|
587
|
-
metadata?: ScheduleMetadata | null;
|
|
588
|
-
serviceUnit: string;
|
|
589
|
-
timerUnit: string;
|
|
590
569
|
}
|
|
591
570
|
|
|
592
|
-
export
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
timerPath: string;
|
|
571
|
+
export function deploy(name: string, options?: Record<string, unknown>): Promise<DeploymentResult>;
|
|
572
|
+
export function promote(name: string, options?: Record<string, unknown>): Promise<PromoteResult>;
|
|
573
|
+
export function rollback(name: string, options?: Record<string, unknown>): Promise<RollbackResult>;
|
|
574
|
+
export function generations(name: string, options?: Record<string, unknown>): GenerationRecord[];
|
|
575
|
+
|
|
576
|
+
export class ProcessManager {
|
|
577
|
+
constructor(options?: Record<string, unknown>);
|
|
578
|
+
start(command: string, args?: string[], options?: Record<string, unknown>): { pid: number; child: any; exitPromise: Promise<any> };
|
|
579
|
+
stop(processOrPid: number | object, options?: { timeout?: number; signal?: string }): Promise<boolean>;
|
|
580
|
+
signal(processOrPid: number | object, signal?: string): boolean;
|
|
581
|
+
isAlive(processOrPid: number | object): boolean;
|
|
582
|
+
waitForExit(processOrPid: number | object, timeout?: number): Promise<{ exited: boolean; code?: number | null; signal?: string | null }>;
|
|
605
583
|
}
|
|
606
584
|
|
|
607
|
-
export
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
export
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
585
|
+
export class GenerationManager {
|
|
586
|
+
constructor(options?: Record<string, unknown>);
|
|
587
|
+
create(serviceName: string, config?: Record<string, unknown>, options?: Record<string, unknown>): Promise<GenerationRecord>;
|
|
588
|
+
getActive(serviceName: string): GenerationRecord | null;
|
|
589
|
+
getPrevious(serviceName: string): GenerationRecord | null;
|
|
590
|
+
getCanary(serviceName: string): GenerationRecord | null;
|
|
591
|
+
getGeneration(serviceName: string, id: number | string): GenerationRecord | null;
|
|
592
|
+
markActive(generation: GenerationRecord): void;
|
|
593
|
+
markCanary(generation: GenerationRecord, weight?: number | string): void;
|
|
594
|
+
markDraining(generation: GenerationRecord): void;
|
|
595
|
+
remove(generation: GenerationRecord, purge?: boolean): void;
|
|
596
|
+
cleanupStale(serviceName: string): number;
|
|
597
|
+
listGenerations(serviceName: string): GenerationRecord[];
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
export class Router {
|
|
601
|
+
constructor(options?: Record<string, unknown>);
|
|
602
|
+
listen(publicPort: number, host?: string): Promise<{ port: number; host: string }>;
|
|
603
|
+
switchBackend(serviceName: string, generation: { id: number; internalPort: number }): void;
|
|
604
|
+
getActiveBackend(serviceName: string): GenerationRecord | null;
|
|
605
|
+
setCanary(serviceName: string, generation: { id: number; internalPort: number }, weight?: number | string): void;
|
|
606
|
+
clearCanary(serviceName: string): void;
|
|
607
|
+
promoteCanary(serviceName: string): void;
|
|
608
|
+
getCanary(serviceName: string): { generation: { id: number; internalPort: number }; weight: number } | null;
|
|
609
|
+
resolveBackend(serviceName: string, req?: any): { id: number; internalPort: number } | null;
|
|
610
|
+
getInFlightCount(generationId: number | string): number;
|
|
611
|
+
close(): Promise<void>;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export class ReadinessChecker {
|
|
615
|
+
constructor(options?: Record<string, unknown>);
|
|
616
|
+
checkTcp(port: number, host?: string, timeout?: number): Promise<boolean>;
|
|
617
|
+
checkHttp(port: number, path?: string, timeout?: number): Promise<boolean>;
|
|
618
|
+
ensure(generation: GenerationRecord, options?: { path?: string }): Promise<boolean>;
|
|
619
|
+
wait(generation: GenerationRecord, options?: { timeout?: number; interval?: number; path?: string }): Promise<boolean>;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export class DrainManager {
|
|
623
|
+
constructor(options?: Record<string, unknown>);
|
|
624
|
+
drain(generation: GenerationRecord, options?: { timeout?: number; pollInterval?: number; stopProcess?: boolean }): Promise<{ drained: boolean; inFlightRemaining: number; timedOut: boolean }>;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
export class DeploymentLock {
|
|
628
|
+
constructor(options?: Record<string, unknown>);
|
|
629
|
+
acquire(serviceName: string): Promise<boolean>;
|
|
630
|
+
release(serviceName: string): Promise<boolean>;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export class DeploymentManager {
|
|
634
|
+
constructor(options?: Record<string, unknown>);
|
|
635
|
+
deploy(serviceName: string, serviceConfig?: Record<string, unknown>, options?: Record<string, unknown>): Promise<DeploymentResult>;
|
|
636
|
+
promote(serviceName: string, serviceConfig?: Record<string, unknown>, options?: Record<string, unknown>): Promise<PromoteResult>;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export class RollbackManager {
|
|
640
|
+
constructor(options?: Record<string, unknown>);
|
|
641
|
+
rollback(serviceName: string, serviceConfig?: Record<string, unknown>, options?: Record<string, unknown>): Promise<RollbackResult>;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export class Supervisor {
|
|
645
|
+
constructor(serviceName: string, serviceConfig?: Record<string, unknown>, options?: Record<string, unknown>);
|
|
646
|
+
start(): Promise<Supervisor>;
|
|
647
|
+
stop(): Promise<void>;
|
|
648
|
+
static run(serviceName: string): Promise<void>;
|
|
649
|
+
}
|
|
626
650
|
|
|
651
|
+
export const defaultDeploymentManager: DeploymentManager;
|
|
652
|
+
export const defaultRollbackManager: RollbackManager;
|
|
627
653
|
|
|
654
|
+
export default defaultManager;
|