@milaboratories/pl-deployments 2.15.16 → 2.15.18
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/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/common/os_and_arch.cjs +22 -28
- package/dist/common/os_and_arch.cjs.map +1 -1
- package/dist/common/os_and_arch.js +23 -26
- package/dist/common/os_and_arch.js.map +1 -1
- package/dist/common/pl_binary.cjs +35 -33
- package/dist/common/pl_binary.cjs.map +1 -1
- package/dist/common/pl_binary.d.ts +13 -18
- package/dist/common/pl_binary.js +33 -31
- package/dist/common/pl_binary.js.map +1 -1
- package/dist/common/pl_binary_download.cjs +143 -155
- package/dist/common/pl_binary_download.cjs.map +1 -1
- package/dist/common/pl_binary_download.d.ts +15 -48
- package/dist/common/pl_binary_download.js +138 -133
- package/dist/common/pl_binary_download.js.map +1 -1
- package/dist/common/pl_version.cjs +5 -6
- package/dist/common/pl_version.cjs.map +1 -1
- package/dist/common/pl_version.d.ts +4 -1
- package/dist/common/pl_version.js +5 -4
- package/dist/common/pl_version.js.map +1 -1
- package/dist/index.cjs +21 -25
- package/dist/index.d.ts +6 -6
- package/dist/index.js +7 -6
- package/dist/local/pid.cjs +14 -13
- package/dist/local/pid.cjs.map +1 -1
- package/dist/local/pid.js +11 -11
- package/dist/local/pid.js.map +1 -1
- package/dist/local/pl.cjs +194 -223
- package/dist/local/pl.cjs.map +1 -1
- package/dist/local/pl.d.ts +65 -65
- package/dist/local/pl.js +190 -202
- package/dist/local/pl.js.map +1 -1
- package/dist/local/process.cjs +37 -59
- package/dist/local/process.cjs.map +1 -1
- package/dist/local/process.d.ts +10 -10
- package/dist/local/process.js +36 -57
- package/dist/local/process.js.map +1 -1
- package/dist/local/trace.cjs +14 -17
- package/dist/local/trace.cjs.map +1 -1
- package/dist/local/trace.d.ts +6 -7
- package/dist/local/trace.js +15 -15
- package/dist/local/trace.js.map +1 -1
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.js +6 -0
- package/dist/package.js.map +1 -0
- package/dist/ssh/connection_info.cjs +36 -53
- package/dist/ssh/connection_info.cjs.map +1 -1
- package/dist/ssh/connection_info.d.ts +691 -713
- package/dist/ssh/connection_info.js +35 -51
- package/dist/ssh/connection_info.js.map +1 -1
- package/dist/ssh/pl.cjs +551 -638
- package/dist/ssh/pl.cjs.map +1 -1
- package/dist/ssh/pl.d.ts +120 -117
- package/dist/ssh/pl.js +548 -636
- package/dist/ssh/pl.js.map +1 -1
- package/dist/ssh/pl_paths.cjs +22 -24
- package/dist/ssh/pl_paths.cjs.map +1 -1
- package/dist/ssh/pl_paths.js +21 -19
- package/dist/ssh/pl_paths.js.map +1 -1
- package/dist/ssh/ssh.cjs +554 -618
- package/dist/ssh/ssh.cjs.map +1 -1
- package/dist/ssh/ssh.d.ts +139 -136
- package/dist/ssh/ssh.js +548 -616
- package/dist/ssh/ssh.js.map +1 -1
- package/dist/ssh/ssh_errors.cjs +45 -60
- package/dist/ssh/ssh_errors.cjs.map +1 -1
- package/dist/ssh/ssh_errors.js +45 -58
- package/dist/ssh/ssh_errors.js.map +1 -1
- package/dist/ssh/supervisord.cjs +50 -68
- package/dist/ssh/supervisord.cjs.map +1 -1
- package/dist/ssh/supervisord.d.ts +11 -21
- package/dist/ssh/supervisord.js +50 -66
- package/dist/ssh/supervisord.js.map +1 -1
- package/package.json +11 -11
- package/dist/common/os_and_arch.d.ts +0 -9
- package/dist/common/os_and_arch.d.ts.map +0 -1
- package/dist/common/pl_binary.d.ts.map +0 -1
- package/dist/common/pl_binary_download.d.ts.map +0 -1
- package/dist/common/pl_version.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/local/options.d.ts +0 -31
- package/dist/local/options.d.ts.map +0 -1
- package/dist/local/pid.d.ts +0 -4
- package/dist/local/pid.d.ts.map +0 -1
- package/dist/local/pl.d.ts.map +0 -1
- package/dist/local/process.d.ts.map +0 -1
- package/dist/local/trace.d.ts.map +0 -1
- package/dist/package.json.cjs +0 -8
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -6
- package/dist/package.json.js.map +0 -1
- package/dist/ssh/__tests__/common-utils.d.ts +0 -12
- package/dist/ssh/__tests__/common-utils.d.ts.map +0 -1
- package/dist/ssh/connection_info.d.ts.map +0 -1
- package/dist/ssh/pl.d.ts.map +0 -1
- package/dist/ssh/pl_paths.d.ts +0 -20
- package/dist/ssh/pl_paths.d.ts.map +0 -1
- package/dist/ssh/ssh.d.ts.map +0 -1
- package/dist/ssh/ssh_errors.d.ts +0 -29
- package/dist/ssh/ssh_errors.d.ts.map +0 -1
- package/dist/ssh/supervisord.d.ts.map +0 -1
package/dist/local/pl.d.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import { ProcessOptions } from "./process.js";
|
|
2
|
+
import { PlBinarySource } from "../common/pl_binary.js";
|
|
3
|
+
import { Trace } from "./trace.js";
|
|
4
|
+
import { SpawnOptions } from "node:child_process";
|
|
5
|
+
import { MiLogger } from "@milaboratories/ts-helpers";
|
|
6
|
+
import { ProxySettings } from "@milaboratories/pl-http";
|
|
7
|
+
import { Required } from "utility-types";
|
|
8
|
+
|
|
9
|
+
//#region src/local/pl.d.ts
|
|
10
|
+
declare const LocalConfigYaml = "config-local.yaml";
|
|
9
11
|
/**
|
|
10
12
|
* Represents a local running pl-core,
|
|
11
13
|
* and has methods to start, check if it's running, stop and wait for stopping it.
|
|
12
14
|
* Also, a hook on pl-core closed can be provided.
|
|
13
15
|
*/
|
|
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
|
-
|
|
16
|
+
declare class LocalPl {
|
|
17
|
+
private readonly logger;
|
|
18
|
+
private readonly workingDir;
|
|
19
|
+
private readonly startOptions;
|
|
20
|
+
private readonly initialStartHistory;
|
|
21
|
+
private readonly onClose?;
|
|
22
|
+
private readonly onError?;
|
|
23
|
+
private readonly onCloseAndError?;
|
|
24
|
+
private readonly onCloseAndErrorNoStop?;
|
|
25
|
+
private instance?;
|
|
26
|
+
pid?: number;
|
|
27
|
+
private nRuns;
|
|
28
|
+
private lastRunHistory;
|
|
29
|
+
private wasStopped;
|
|
30
|
+
constructor(logger: MiLogger, workingDir: string, startOptions: ProcessOptions, initialStartHistory: Trace, onClose?: ((pl: LocalPl) => Promise<void>) | undefined, onError?: ((pl: LocalPl) => Promise<void>) | undefined, onCloseAndError?: ((pl: LocalPl) => Promise<void>) | undefined, onCloseAndErrorNoStop?: ((pl: LocalPl) => Promise<void>) | undefined);
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
stop(): void;
|
|
33
|
+
waitStopped(): Promise<void>;
|
|
34
|
+
stopped(): boolean;
|
|
35
|
+
isAlive(): Promise<boolean>;
|
|
36
|
+
debugInfo(): {
|
|
37
|
+
lastRunHistory: Trace;
|
|
38
|
+
nRuns: number;
|
|
39
|
+
pid: number | undefined;
|
|
40
|
+
workingDir: string;
|
|
41
|
+
initialStartHistory: Trace;
|
|
42
|
+
wasStopped: boolean;
|
|
43
|
+
};
|
|
42
44
|
}
|
|
43
45
|
/** Options to start a local pl-core. */
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
readonly onClose?: (pl: LocalPl) => Promise<void>;
|
|
66
|
-
readonly onError?: (pl: LocalPl) => Promise<void>;
|
|
67
|
-
readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;
|
|
68
|
-
readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;
|
|
46
|
+
type LocalPlOptions = {
|
|
47
|
+
/** From what directory start a process. */readonly workingDir: string; /** A string representation of yaml config. */
|
|
48
|
+
readonly config: string; /** How to get a binary, download it or get an existing one (default: download latest version) */
|
|
49
|
+
readonly plBinary?: PlBinarySource; /** Additional options for a process, environments, stdout, stderr etc. */
|
|
50
|
+
readonly spawnOptions?: SpawnOptions;
|
|
51
|
+
/**
|
|
52
|
+
* If the previous pl-core was started from the same directory,
|
|
53
|
+
* we can check if it's still running and then stop it before starting a new one.
|
|
54
|
+
* (default: true)
|
|
55
|
+
*/
|
|
56
|
+
readonly closeOld?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Proxy settings to use to fetch the binary and pass it down
|
|
59
|
+
* as a HTTPS_PROXY/HTTP_PROXY environment variable;
|
|
60
|
+
* Backend only supports Basic auth.
|
|
61
|
+
*/
|
|
62
|
+
readonly proxy?: ProxySettings;
|
|
63
|
+
readonly onClose?: (pl: LocalPl) => Promise<void>;
|
|
64
|
+
readonly onError?: (pl: LocalPl) => Promise<void>;
|
|
65
|
+
readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;
|
|
66
|
+
readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;
|
|
69
67
|
};
|
|
70
|
-
|
|
68
|
+
type LocalPlOptionsFull = Required<LocalPlOptions, "plBinary" | "spawnOptions" | "closeOld">;
|
|
71
69
|
/**
|
|
72
70
|
* Starts pl-core, if the option was provided downloads a binary, reads license environments etc.
|
|
73
71
|
*/
|
|
74
|
-
|
|
72
|
+
declare function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions): Promise<LocalPl>;
|
|
75
73
|
/** Gets default options for the whole init process
|
|
76
74
|
* and overrides them with the provided options. */
|
|
77
|
-
|
|
75
|
+
declare function mergeDefaultOps(ops: LocalPlOptions, numCpu: number): LocalPlOptionsFull;
|
|
78
76
|
/** Gets default options for a platforma local binary
|
|
79
77
|
* and overrides them with the provided options. */
|
|
80
|
-
|
|
78
|
+
declare function plProcessOps(binaryPath: any, configPath: string, ops: LocalPlOptionsFull, workDir: string, defaultEnv: Record<string, string | undefined>): ProcessOptions;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { LocalConfigYaml, LocalPl, LocalPlOptions, LocalPlOptionsFull, localPlatformaInit, mergeDefaultOps, plProcessOps };
|
|
81
81
|
//# sourceMappingURL=pl.d.ts.map
|
package/dist/local/pl.js
CHANGED
|
@@ -1,221 +1,209 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import * as os from
|
|
9
|
-
import { defaultHttpDispatcher } from
|
|
10
|
-
import { parseHttpAuth } from
|
|
1
|
+
import { isProcessAlive, processRun, processStop, processWaitStopped } from "./process.js";
|
|
2
|
+
import { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from "../common/pl_binary.js";
|
|
3
|
+
import { filePid, readPid, writePid } from "./pid.js";
|
|
4
|
+
import { withTrace } from "./trace.js";
|
|
5
|
+
import { notEmpty } from "@milaboratories/ts-helpers";
|
|
6
|
+
import fsp from "node:fs/promises";
|
|
7
|
+
import upath from "upath";
|
|
8
|
+
import * as os$1 from "node:os";
|
|
9
|
+
import { defaultHttpDispatcher } from "@milaboratories/pl-http";
|
|
10
|
+
import { parseHttpAuth } from "@milaboratories/pl-model-common";
|
|
11
11
|
|
|
12
|
+
//#region src/local/pl.ts
|
|
12
13
|
const LocalConfigYaml = "config-local.yaml";
|
|
13
14
|
/**
|
|
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
|
-
stopped() {
|
|
85
|
-
return this.wasStopped;
|
|
86
|
-
}
|
|
87
|
-
async isAlive() {
|
|
88
|
-
return await isProcessAlive(notEmpty(this.pid));
|
|
89
|
-
}
|
|
90
|
-
debugInfo() {
|
|
91
|
-
return {
|
|
92
|
-
lastRunHistory: this.lastRunHistory,
|
|
93
|
-
nRuns: this.nRuns,
|
|
94
|
-
pid: this.pid,
|
|
95
|
-
workingDir: this.workingDir,
|
|
96
|
-
initialStartHistory: this.initialStartHistory,
|
|
97
|
-
wasStopped: this.wasStopped,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
}
|
|
15
|
+
* Represents a local running pl-core,
|
|
16
|
+
* and has methods to start, check if it's running, stop and wait for stopping it.
|
|
17
|
+
* Also, a hook on pl-core closed can be provided.
|
|
18
|
+
*/
|
|
19
|
+
var LocalPl = class {
|
|
20
|
+
instance;
|
|
21
|
+
pid;
|
|
22
|
+
nRuns = 0;
|
|
23
|
+
lastRunHistory = {};
|
|
24
|
+
wasStopped = false;
|
|
25
|
+
constructor(logger, workingDir, startOptions, initialStartHistory, onClose, onError, onCloseAndError, onCloseAndErrorNoStop) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.workingDir = workingDir;
|
|
28
|
+
this.startOptions = startOptions;
|
|
29
|
+
this.initialStartHistory = initialStartHistory;
|
|
30
|
+
this.onClose = onClose;
|
|
31
|
+
this.onError = onError;
|
|
32
|
+
this.onCloseAndError = onCloseAndError;
|
|
33
|
+
this.onCloseAndErrorNoStop = onCloseAndErrorNoStop;
|
|
34
|
+
}
|
|
35
|
+
async start() {
|
|
36
|
+
await withTrace(this.logger, async (trace, t) => {
|
|
37
|
+
this.wasStopped = false;
|
|
38
|
+
const instance = processRun(this.logger, this.startOptions);
|
|
39
|
+
instance.on("error", (e) => {
|
|
40
|
+
this.logger.error(`error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`);
|
|
41
|
+
if (this.onError !== void 0) this.onError(this);
|
|
42
|
+
if (this.onCloseAndError !== void 0) this.onCloseAndError(this);
|
|
43
|
+
if (this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped) this.onCloseAndErrorNoStop(this);
|
|
44
|
+
});
|
|
45
|
+
instance.on("close", () => {
|
|
46
|
+
this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);
|
|
47
|
+
if (this.onClose !== void 0) this.onClose(this);
|
|
48
|
+
if (this.onCloseAndError !== void 0) this.onCloseAndError(this);
|
|
49
|
+
if (this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped) this.onCloseAndErrorNoStop(this);
|
|
50
|
+
});
|
|
51
|
+
trace("started", true);
|
|
52
|
+
const pidFile = trace("pidFile", filePid(this.workingDir));
|
|
53
|
+
trace("pid", notEmpty(instance.pid));
|
|
54
|
+
trace("pidWritten", await writePid(pidFile, notEmpty(instance.pid)));
|
|
55
|
+
this.nRuns++;
|
|
56
|
+
this.instance = instance;
|
|
57
|
+
this.pid = instance.pid;
|
|
58
|
+
this.lastRunHistory = t;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
stop() {
|
|
62
|
+
this.wasStopped = true;
|
|
63
|
+
processStop(notEmpty(this.pid));
|
|
64
|
+
}
|
|
65
|
+
async waitStopped() {
|
|
66
|
+
await processWaitStopped(notEmpty(this.pid), 15e3);
|
|
67
|
+
}
|
|
68
|
+
stopped() {
|
|
69
|
+
return this.wasStopped;
|
|
70
|
+
}
|
|
71
|
+
async isAlive() {
|
|
72
|
+
return await isProcessAlive(notEmpty(this.pid));
|
|
73
|
+
}
|
|
74
|
+
debugInfo() {
|
|
75
|
+
return {
|
|
76
|
+
lastRunHistory: this.lastRunHistory,
|
|
77
|
+
nRuns: this.nRuns,
|
|
78
|
+
pid: this.pid,
|
|
79
|
+
workingDir: this.workingDir,
|
|
80
|
+
initialStartHistory: this.initialStartHistory,
|
|
81
|
+
wasStopped: this.wasStopped
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
101
85
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
* Starts pl-core, if the option was provided downloads a binary, reads license environments etc.
|
|
87
|
+
*/
|
|
104
88
|
async function localPlatformaInit(logger, _ops) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const url = new URL(ops.proxy.url);
|
|
130
|
-
if (ops.proxy.auth) {
|
|
131
|
-
const parsed = parseHttpAuth(ops.proxy.auth);
|
|
132
|
-
if (parsed.scheme !== "Basic") {
|
|
133
|
-
throw new Error(`\
|
|
89
|
+
const ops = mergeDefaultOps(_ops, Math.max(os$1.cpus().length - 2, 1));
|
|
90
|
+
return await withTrace(logger, async (trace, t) => {
|
|
91
|
+
trace("startOptions", {
|
|
92
|
+
...ops,
|
|
93
|
+
config: "too wordy"
|
|
94
|
+
});
|
|
95
|
+
const workDir = upath.resolve(ops.workingDir);
|
|
96
|
+
if (ops.closeOld) trace("closeOld", await localPlatformaReadPidAndStop(logger, workDir));
|
|
97
|
+
const configPath = upath.join(workDir, LocalConfigYaml);
|
|
98
|
+
logger.info(`writing configuration '${configPath}'...`);
|
|
99
|
+
await fsp.writeFile(configPath, ops.config);
|
|
100
|
+
const baseBinaryPath = await resolveLocalPlBinaryPath({
|
|
101
|
+
logger,
|
|
102
|
+
downloadDir: upath.join(workDir, "binaries"),
|
|
103
|
+
src: ops.plBinary,
|
|
104
|
+
dispatcher: defaultHttpDispatcher(ops.proxy)
|
|
105
|
+
});
|
|
106
|
+
const binaryPath = trace("binaryPath", upath.join("binaries", baseBinaryPath));
|
|
107
|
+
const env = { ...process.env };
|
|
108
|
+
if (ops.proxy?.url) {
|
|
109
|
+
const url = new URL(ops.proxy.url);
|
|
110
|
+
if (ops.proxy.auth) {
|
|
111
|
+
const parsed = parseHttpAuth(ops.proxy.auth);
|
|
112
|
+
if (parsed.scheme !== "Basic") throw new Error(`\
|
|
134
113
|
Unsupported auth scheme: ${parsed.scheme}. \
|
|
135
114
|
Only Basic auth is supported by the backend.`);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
115
|
+
url.username = parsed.username;
|
|
116
|
+
url.password = parsed.password;
|
|
117
|
+
}
|
|
118
|
+
env.http_proxy = url.toString();
|
|
119
|
+
env.https_proxy = url.toString();
|
|
120
|
+
}
|
|
121
|
+
const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);
|
|
122
|
+
trace("processOpts", {
|
|
123
|
+
cmd: processOpts.cmd,
|
|
124
|
+
args: processOpts.args,
|
|
125
|
+
cwd: processOpts.opts.cwd
|
|
126
|
+
});
|
|
127
|
+
const pl = new LocalPl(logger, ops.workingDir, processOpts, t, ops.onClose, ops.onError, ops.onCloseAndError, ops.onCloseAndErrorNoStop);
|
|
128
|
+
await pl.start();
|
|
129
|
+
return pl;
|
|
130
|
+
});
|
|
153
131
|
}
|
|
154
132
|
/** Reads a pid of the old pl-core if it was started in the same working directory,
|
|
155
|
-
|
|
133
|
+
* and closes it. */
|
|
156
134
|
async function localPlatformaReadPidAndStop(logger, workingDir) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return t;
|
|
172
|
-
});
|
|
135
|
+
return await withTrace(logger, async (trace, t) => {
|
|
136
|
+
const oldPid = trace("pid", await readPid(trace("pidFilePath", filePid(workingDir))));
|
|
137
|
+
const alive = trace("wasAlive", await isProcessAlive(oldPid));
|
|
138
|
+
if (oldPid !== void 0 && alive) {
|
|
139
|
+
trace("stopped", processStop(oldPid));
|
|
140
|
+
try {
|
|
141
|
+
trace("waitStopped", await processWaitStopped(oldPid, 15e3));
|
|
142
|
+
} catch {
|
|
143
|
+
trace("forceStopped", processStop(oldPid, true));
|
|
144
|
+
trace("waitForceStopped", await processWaitStopped(oldPid, 5e3));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return t;
|
|
148
|
+
});
|
|
173
149
|
}
|
|
174
150
|
/** Gets default options for the whole init process
|
|
175
|
-
|
|
151
|
+
* and overrides them with the provided options. */
|
|
176
152
|
function mergeDefaultOps(ops, numCpu) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
153
|
+
const result = {
|
|
154
|
+
plBinary: newDefaultPlBinarySource(),
|
|
155
|
+
spawnOptions: { env: { GOMAXPROCS: String(numCpu) } },
|
|
156
|
+
closeOld: true
|
|
157
|
+
};
|
|
158
|
+
if (ops.spawnOptions?.env) result.spawnOptions.env = {
|
|
159
|
+
...result.spawnOptions.env,
|
|
160
|
+
...ops.spawnOptions.env
|
|
161
|
+
};
|
|
162
|
+
if (ops.spawnOptions) {
|
|
163
|
+
const withoutEnv = { ...ops.spawnOptions };
|
|
164
|
+
delete withoutEnv["env"];
|
|
165
|
+
result.spawnOptions = {
|
|
166
|
+
...result.spawnOptions,
|
|
167
|
+
...withoutEnv
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
const withoutSpawnOps = { ...ops };
|
|
171
|
+
delete withoutSpawnOps["spawnOptions"];
|
|
172
|
+
return {
|
|
173
|
+
...result,
|
|
174
|
+
...withoutSpawnOps
|
|
175
|
+
};
|
|
197
176
|
}
|
|
198
177
|
/** Gets default options for a platforma local binary
|
|
199
|
-
|
|
178
|
+
* and overrides them with the provided options. */
|
|
200
179
|
function plProcessOps(binaryPath, configPath, ops, workDir, defaultEnv) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
180
|
+
const result = {
|
|
181
|
+
cmd: binaryPath,
|
|
182
|
+
args: ["--config", configPath],
|
|
183
|
+
opts: {
|
|
184
|
+
env: { ...defaultEnv },
|
|
185
|
+
cwd: workDir,
|
|
186
|
+
stdio: [
|
|
187
|
+
"pipe",
|
|
188
|
+
"ignore",
|
|
189
|
+
"inherit"
|
|
190
|
+
],
|
|
191
|
+
windowsHide: true
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
if (ops.spawnOptions?.env) result.opts.env = {
|
|
195
|
+
...result.opts.env,
|
|
196
|
+
...ops.spawnOptions.env
|
|
197
|
+
};
|
|
198
|
+
const withoutEnv = { ...ops.spawnOptions };
|
|
199
|
+
delete withoutEnv["env"];
|
|
200
|
+
result.opts = {
|
|
201
|
+
...result.opts,
|
|
202
|
+
...withoutEnv
|
|
203
|
+
};
|
|
204
|
+
return result;
|
|
218
205
|
}
|
|
219
206
|
|
|
207
|
+
//#endregion
|
|
220
208
|
export { LocalConfigYaml, LocalPl, localPlatformaInit, mergeDefaultOps, plProcessOps };
|
|
221
|
-
//# sourceMappingURL=pl.js.map
|
|
209
|
+
//# sourceMappingURL=pl.js.map
|