-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChildProcessService.ts
86 lines (73 loc) · 2.1 KB
/
ChildProcessService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) 2023. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.
import { Disposable } from "./types/Disposable";
import { DisposeAware } from "./types/DisposeAware";
export interface CommandEnvironment {
readonly [key: string]: string;
}
export interface CommandOptions {
readonly cwd ?: string;
readonly env ?: CommandEnvironment;
readonly argv0 ?: string;
readonly serialization ?: string;
readonly timeout ?: number;
readonly uid ?: number;
readonly gid ?: number;
readonly killSignal ?: string | number;
readonly maxBuffer ?: number;
readonly stdio ?: string | readonly string[];
readonly detached ?: boolean;
}
export interface CommandResponse {
readonly name : string;
readonly args : readonly string[];
readonly output : string;
readonly errors ?: string;
}
/**
* Interface for running child processes in a system.
*
* The system may be a NodeJS environment or later some external backend
* through an HTTP API. E.g. there could be a frontend client implementation as
* well.
*
* @see {@link NodeChildProcessService}
*/
export interface ChildProcessService extends Disposable, DisposeAware {
/**
* Destroy the service and free any resources. Do not use the service
* again after you have called this method.
*/
destroy () : void;
/**
* Returns true if the service has been destroyed
*/
isDestroyed () : boolean;
/**
* Returns the amount of children running
*/
countChildProcesses () : Promise<number>;
/**
* Wait until all the started children have stopped
*/
waitAllChildProcessesStopped () : Promise<void>;
/**
* Close any child processes running
*/
shutdownChildProcesses () : Promise<void>;
/**
* Starts a new child process to run a command.
*
* @param name
* @param args
* @param opts
*/
executeCommand (
name : string,
args ?: readonly string[],
opts ?: CommandOptions
) : Promise<CommandResponse>;
/**
*
*/
sendShutdownToChildProcesses () : void;
}