@milaboratories/pl-deployments 2.15.17 → 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 +9 -9
- 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.cjs
CHANGED
|
@@ -1,246 +1,217 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var n = Object.create(null);
|
|
16
|
-
if (e) {
|
|
17
|
-
Object.keys(e).forEach(function (k) {
|
|
18
|
-
if (k !== 'default') {
|
|
19
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () { return e[k]; }
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
n.default = e;
|
|
28
|
-
return Object.freeze(n);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_process = require('./process.cjs');
|
|
3
|
+
const require_pl_binary = require('../common/pl_binary.cjs');
|
|
4
|
+
const require_pid = require('./pid.cjs');
|
|
5
|
+
const require_trace = require('./trace.cjs');
|
|
6
|
+
let _milaboratories_ts_helpers = require("@milaboratories/ts-helpers");
|
|
7
|
+
let node_fs_promises = require("node:fs/promises");
|
|
8
|
+
node_fs_promises = require_runtime.__toESM(node_fs_promises);
|
|
9
|
+
let upath = require("upath");
|
|
10
|
+
upath = require_runtime.__toESM(upath);
|
|
11
|
+
let node_os = require("node:os");
|
|
12
|
+
node_os = require_runtime.__toESM(node_os);
|
|
13
|
+
let _milaboratories_pl_http = require("@milaboratories/pl-http");
|
|
14
|
+
let _milaboratories_pl_model_common = require("@milaboratories/pl-model-common");
|
|
32
15
|
|
|
16
|
+
//#region src/local/pl.ts
|
|
33
17
|
const LocalConfigYaml = "config-local.yaml";
|
|
34
18
|
/**
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
stopped() {
|
|
106
|
-
return this.wasStopped;
|
|
107
|
-
}
|
|
108
|
-
async isAlive() {
|
|
109
|
-
return await process$1.isProcessAlive(tsHelpers.notEmpty(this.pid));
|
|
110
|
-
}
|
|
111
|
-
debugInfo() {
|
|
112
|
-
return {
|
|
113
|
-
lastRunHistory: this.lastRunHistory,
|
|
114
|
-
nRuns: this.nRuns,
|
|
115
|
-
pid: this.pid,
|
|
116
|
-
workingDir: this.workingDir,
|
|
117
|
-
initialStartHistory: this.initialStartHistory,
|
|
118
|
-
wasStopped: this.wasStopped,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
19
|
+
* Represents a local running pl-core,
|
|
20
|
+
* and has methods to start, check if it's running, stop and wait for stopping it.
|
|
21
|
+
* Also, a hook on pl-core closed can be provided.
|
|
22
|
+
*/
|
|
23
|
+
var LocalPl = class {
|
|
24
|
+
instance;
|
|
25
|
+
pid;
|
|
26
|
+
nRuns = 0;
|
|
27
|
+
lastRunHistory = {};
|
|
28
|
+
wasStopped = false;
|
|
29
|
+
constructor(logger, workingDir, startOptions, initialStartHistory, onClose, onError, onCloseAndError, onCloseAndErrorNoStop) {
|
|
30
|
+
this.logger = logger;
|
|
31
|
+
this.workingDir = workingDir;
|
|
32
|
+
this.startOptions = startOptions;
|
|
33
|
+
this.initialStartHistory = initialStartHistory;
|
|
34
|
+
this.onClose = onClose;
|
|
35
|
+
this.onError = onError;
|
|
36
|
+
this.onCloseAndError = onCloseAndError;
|
|
37
|
+
this.onCloseAndErrorNoStop = onCloseAndErrorNoStop;
|
|
38
|
+
}
|
|
39
|
+
async start() {
|
|
40
|
+
await require_trace.withTrace(this.logger, async (trace, t) => {
|
|
41
|
+
this.wasStopped = false;
|
|
42
|
+
const instance = require_process.processRun(this.logger, this.startOptions);
|
|
43
|
+
instance.on("error", (e) => {
|
|
44
|
+
this.logger.error(`error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`);
|
|
45
|
+
if (this.onError !== void 0) this.onError(this);
|
|
46
|
+
if (this.onCloseAndError !== void 0) this.onCloseAndError(this);
|
|
47
|
+
if (this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped) this.onCloseAndErrorNoStop(this);
|
|
48
|
+
});
|
|
49
|
+
instance.on("close", () => {
|
|
50
|
+
this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);
|
|
51
|
+
if (this.onClose !== void 0) this.onClose(this);
|
|
52
|
+
if (this.onCloseAndError !== void 0) this.onCloseAndError(this);
|
|
53
|
+
if (this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped) this.onCloseAndErrorNoStop(this);
|
|
54
|
+
});
|
|
55
|
+
trace("started", true);
|
|
56
|
+
const pidFile = trace("pidFile", require_pid.filePid(this.workingDir));
|
|
57
|
+
trace("pid", (0, _milaboratories_ts_helpers.notEmpty)(instance.pid));
|
|
58
|
+
trace("pidWritten", await require_pid.writePid(pidFile, (0, _milaboratories_ts_helpers.notEmpty)(instance.pid)));
|
|
59
|
+
this.nRuns++;
|
|
60
|
+
this.instance = instance;
|
|
61
|
+
this.pid = instance.pid;
|
|
62
|
+
this.lastRunHistory = t;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
stop() {
|
|
66
|
+
this.wasStopped = true;
|
|
67
|
+
require_process.processStop((0, _milaboratories_ts_helpers.notEmpty)(this.pid));
|
|
68
|
+
}
|
|
69
|
+
async waitStopped() {
|
|
70
|
+
await require_process.processWaitStopped((0, _milaboratories_ts_helpers.notEmpty)(this.pid), 15e3);
|
|
71
|
+
}
|
|
72
|
+
stopped() {
|
|
73
|
+
return this.wasStopped;
|
|
74
|
+
}
|
|
75
|
+
async isAlive() {
|
|
76
|
+
return await require_process.isProcessAlive((0, _milaboratories_ts_helpers.notEmpty)(this.pid));
|
|
77
|
+
}
|
|
78
|
+
debugInfo() {
|
|
79
|
+
return {
|
|
80
|
+
lastRunHistory: this.lastRunHistory,
|
|
81
|
+
nRuns: this.nRuns,
|
|
82
|
+
pid: this.pid,
|
|
83
|
+
workingDir: this.workingDir,
|
|
84
|
+
initialStartHistory: this.initialStartHistory,
|
|
85
|
+
wasStopped: this.wasStopped
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
};
|
|
122
89
|
/**
|
|
123
|
-
|
|
124
|
-
|
|
90
|
+
* Starts pl-core, if the option was provided downloads a binary, reads license environments etc.
|
|
91
|
+
*/
|
|
125
92
|
async function localPlatformaInit(logger, _ops) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const url = new URL(ops.proxy.url);
|
|
151
|
-
if (ops.proxy.auth) {
|
|
152
|
-
const parsed = plModelCommon.parseHttpAuth(ops.proxy.auth);
|
|
153
|
-
if (parsed.scheme !== "Basic") {
|
|
154
|
-
throw new Error(`\
|
|
93
|
+
const ops = mergeDefaultOps(_ops, Math.max(node_os.cpus().length - 2, 1));
|
|
94
|
+
return await require_trace.withTrace(logger, async (trace, t) => {
|
|
95
|
+
trace("startOptions", {
|
|
96
|
+
...ops,
|
|
97
|
+
config: "too wordy"
|
|
98
|
+
});
|
|
99
|
+
const workDir = upath.default.resolve(ops.workingDir);
|
|
100
|
+
if (ops.closeOld) trace("closeOld", await localPlatformaReadPidAndStop(logger, workDir));
|
|
101
|
+
const configPath = upath.default.join(workDir, LocalConfigYaml);
|
|
102
|
+
logger.info(`writing configuration '${configPath}'...`);
|
|
103
|
+
await node_fs_promises.default.writeFile(configPath, ops.config);
|
|
104
|
+
const baseBinaryPath = await require_pl_binary.resolveLocalPlBinaryPath({
|
|
105
|
+
logger,
|
|
106
|
+
downloadDir: upath.default.join(workDir, "binaries"),
|
|
107
|
+
src: ops.plBinary,
|
|
108
|
+
dispatcher: (0, _milaboratories_pl_http.defaultHttpDispatcher)(ops.proxy)
|
|
109
|
+
});
|
|
110
|
+
const binaryPath = trace("binaryPath", upath.default.join("binaries", baseBinaryPath));
|
|
111
|
+
const env = { ...process.env };
|
|
112
|
+
if (ops.proxy?.url) {
|
|
113
|
+
const url = new URL(ops.proxy.url);
|
|
114
|
+
if (ops.proxy.auth) {
|
|
115
|
+
const parsed = (0, _milaboratories_pl_model_common.parseHttpAuth)(ops.proxy.auth);
|
|
116
|
+
if (parsed.scheme !== "Basic") throw new Error(`\
|
|
155
117
|
Unsupported auth scheme: ${parsed.scheme}. \
|
|
156
118
|
Only Basic auth is supported by the backend.`);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
119
|
+
url.username = parsed.username;
|
|
120
|
+
url.password = parsed.password;
|
|
121
|
+
}
|
|
122
|
+
env.http_proxy = url.toString();
|
|
123
|
+
env.https_proxy = url.toString();
|
|
124
|
+
}
|
|
125
|
+
const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);
|
|
126
|
+
trace("processOpts", {
|
|
127
|
+
cmd: processOpts.cmd,
|
|
128
|
+
args: processOpts.args,
|
|
129
|
+
cwd: processOpts.opts.cwd
|
|
130
|
+
});
|
|
131
|
+
const pl = new LocalPl(logger, ops.workingDir, processOpts, t, ops.onClose, ops.onError, ops.onCloseAndError, ops.onCloseAndErrorNoStop);
|
|
132
|
+
await pl.start();
|
|
133
|
+
return pl;
|
|
134
|
+
});
|
|
174
135
|
}
|
|
175
136
|
/** Reads a pid of the old pl-core if it was started in the same working directory,
|
|
176
|
-
|
|
137
|
+
* and closes it. */
|
|
177
138
|
async function localPlatformaReadPidAndStop(logger, workingDir) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
return t;
|
|
193
|
-
});
|
|
139
|
+
return await require_trace.withTrace(logger, async (trace, t) => {
|
|
140
|
+
const oldPid = trace("pid", await require_pid.readPid(trace("pidFilePath", require_pid.filePid(workingDir))));
|
|
141
|
+
const alive = trace("wasAlive", await require_process.isProcessAlive(oldPid));
|
|
142
|
+
if (oldPid !== void 0 && alive) {
|
|
143
|
+
trace("stopped", require_process.processStop(oldPid));
|
|
144
|
+
try {
|
|
145
|
+
trace("waitStopped", await require_process.processWaitStopped(oldPid, 15e3));
|
|
146
|
+
} catch {
|
|
147
|
+
trace("forceStopped", require_process.processStop(oldPid, true));
|
|
148
|
+
trace("waitForceStopped", await require_process.processWaitStopped(oldPid, 5e3));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return t;
|
|
152
|
+
});
|
|
194
153
|
}
|
|
195
154
|
/** Gets default options for the whole init process
|
|
196
|
-
|
|
155
|
+
* and overrides them with the provided options. */
|
|
197
156
|
function mergeDefaultOps(ops, numCpu) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
157
|
+
const result = {
|
|
158
|
+
plBinary: require_pl_binary.newDefaultPlBinarySource(),
|
|
159
|
+
spawnOptions: { env: { GOMAXPROCS: String(numCpu) } },
|
|
160
|
+
closeOld: true
|
|
161
|
+
};
|
|
162
|
+
if (ops.spawnOptions?.env) result.spawnOptions.env = {
|
|
163
|
+
...result.spawnOptions.env,
|
|
164
|
+
...ops.spawnOptions.env
|
|
165
|
+
};
|
|
166
|
+
if (ops.spawnOptions) {
|
|
167
|
+
const withoutEnv = { ...ops.spawnOptions };
|
|
168
|
+
delete withoutEnv["env"];
|
|
169
|
+
result.spawnOptions = {
|
|
170
|
+
...result.spawnOptions,
|
|
171
|
+
...withoutEnv
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const withoutSpawnOps = { ...ops };
|
|
175
|
+
delete withoutSpawnOps["spawnOptions"];
|
|
176
|
+
return {
|
|
177
|
+
...result,
|
|
178
|
+
...withoutSpawnOps
|
|
179
|
+
};
|
|
218
180
|
}
|
|
219
181
|
/** Gets default options for a platforma local binary
|
|
220
|
-
|
|
182
|
+
* and overrides them with the provided options. */
|
|
221
183
|
function plProcessOps(binaryPath, configPath, ops, workDir, defaultEnv) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
184
|
+
const result = {
|
|
185
|
+
cmd: binaryPath,
|
|
186
|
+
args: ["--config", configPath],
|
|
187
|
+
opts: {
|
|
188
|
+
env: { ...defaultEnv },
|
|
189
|
+
cwd: workDir,
|
|
190
|
+
stdio: [
|
|
191
|
+
"pipe",
|
|
192
|
+
"ignore",
|
|
193
|
+
"inherit"
|
|
194
|
+
],
|
|
195
|
+
windowsHide: true
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
if (ops.spawnOptions?.env) result.opts.env = {
|
|
199
|
+
...result.opts.env,
|
|
200
|
+
...ops.spawnOptions.env
|
|
201
|
+
};
|
|
202
|
+
const withoutEnv = { ...ops.spawnOptions };
|
|
203
|
+
delete withoutEnv["env"];
|
|
204
|
+
result.opts = {
|
|
205
|
+
...result.opts,
|
|
206
|
+
...withoutEnv
|
|
207
|
+
};
|
|
208
|
+
return result;
|
|
239
209
|
}
|
|
240
210
|
|
|
211
|
+
//#endregion
|
|
241
212
|
exports.LocalConfigYaml = LocalConfigYaml;
|
|
242
213
|
exports.LocalPl = LocalPl;
|
|
243
214
|
exports.localPlatformaInit = localPlatformaInit;
|
|
244
215
|
exports.mergeDefaultOps = mergeDefaultOps;
|
|
245
216
|
exports.plProcessOps = plProcessOps;
|
|
246
|
-
//# sourceMappingURL=pl.cjs.map
|
|
217
|
+
//# sourceMappingURL=pl.cjs.map
|
package/dist/local/pl.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.cjs","sources":["../../src/local/pl.ts"],"sourcesContent":["import type { ProcessOptions } from \"./process\";\nimport { isProcessAlive, processStop, processWaitStopped, processRun } from \"./process\";\nimport type { PlBinarySource } from \"../common/pl_binary\";\nimport { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from \"../common/pl_binary\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { filePid, readPid, writePid } from \"./pid\";\nimport type { Trace } from \"./trace\";\nimport { withTrace } from \"./trace\";\nimport upath from \"upath\";\nimport fsp from \"node:fs/promises\";\nimport type { Required } from \"utility-types\";\nimport * as os from \"node:os\";\nimport type { ProxySettings } from \"@milaboratories/pl-http\";\nimport { defaultHttpDispatcher } from \"@milaboratories/pl-http\";\nimport { parseHttpAuth } from \"@milaboratories/pl-model-common\";\n\nexport const LocalConfigYaml = \"config-local.yaml\";\n\n/**\n * Represents a local running pl-core,\n * and has methods to start, check if it's running, stop and wait for stopping it.\n * Also, a hook on pl-core closed can be provided.\n */\nexport class LocalPl {\n private instance?: ChildProcess;\n public pid?: number;\n private nRuns: number = 0;\n private lastRunHistory: Trace = {};\n private wasStopped = false;\n\n constructor(\n private readonly logger: MiLogger,\n private readonly workingDir: string,\n private readonly startOptions: ProcessOptions,\n private readonly initialStartHistory: Trace,\n private readonly onClose?: (pl: LocalPl) => Promise<void>,\n private readonly onError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>,\n ) {}\n\n async start() {\n await withTrace(this.logger, async (trace, t) => {\n this.wasStopped = false;\n const instance = processRun(this.logger, this.startOptions);\n instance.on(\"error\", (e: any) => {\n this.logger.error(\n `error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`,\n );\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onError !== undefined) void this.onError(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n instance.on(\"close\", () => {\n this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onClose !== undefined) void this.onClose(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n\n trace(\"started\", true);\n\n const pidFile = trace(\"pidFile\", filePid(this.workingDir));\n trace(\"pid\", notEmpty(instance.pid));\n trace(\"pidWritten\", await writePid(pidFile, notEmpty(instance.pid)));\n\n this.nRuns++;\n this.instance = instance;\n this.pid = instance.pid;\n this.lastRunHistory = t;\n });\n }\n\n stop() {\n // TODO use this.instance to stop the process\n this.wasStopped = true;\n processStop(notEmpty(this.pid));\n }\n\n async waitStopped() {\n await processWaitStopped(notEmpty(this.pid), 15000);\n }\n\n stopped() {\n return this.wasStopped;\n }\n\n async isAlive(): Promise<boolean> {\n return await isProcessAlive(notEmpty(this.pid));\n }\n\n debugInfo() {\n return {\n lastRunHistory: this.lastRunHistory,\n nRuns: this.nRuns,\n pid: this.pid,\n workingDir: this.workingDir,\n initialStartHistory: this.initialStartHistory,\n wasStopped: this.wasStopped,\n };\n }\n}\n\n/** Options to start a local pl-core. */\nexport type LocalPlOptions = {\n /** From what directory start a process. */\n readonly workingDir: string;\n /** A string representation of yaml config. */\n readonly config: string;\n /** How to get a binary, download it or get an existing one (default: download latest version) */\n readonly plBinary?: PlBinarySource;\n /** Additional options for a process, environments, stdout, stderr etc. */\n readonly spawnOptions?: SpawnOptions;\n /**\n * If the previous pl-core was started from the same directory,\n * we can check if it's still running and then stop it before starting a new one.\n * (default: true)\n */\n readonly closeOld?: boolean;\n /**\n * Proxy settings to use to fetch the binary and pass it down\n * as a HTTPS_PROXY/HTTP_PROXY environment variable;\n * Backend only supports Basic auth.\n */\n readonly proxy?: ProxySettings;\n\n readonly onClose?: (pl: LocalPl) => Promise<void>;\n readonly onError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;\n};\n\nexport type LocalPlOptionsFull = Required<LocalPlOptions, \"plBinary\" | \"spawnOptions\" | \"closeOld\">;\n\n/**\n * Starts pl-core, if the option was provided downloads a binary, reads license environments etc.\n */\nexport async function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions): Promise<LocalPl> {\n // filling-in default values\n\n // Backend could consume a lot of CPU power,\n // we want to keep at least a couple for UI and other apps to work.\n const numCpu = Math.max(os.cpus().length - 2, 1);\n const ops = mergeDefaultOps(_ops, numCpu);\n\n return await withTrace(logger, async (trace, t) => {\n trace(\"startOptions\", { ...ops, config: \"too wordy\" });\n\n const workDir = upath.resolve(ops.workingDir);\n\n if (ops.closeOld) {\n trace(\"closeOld\", await localPlatformaReadPidAndStop(logger, workDir));\n }\n\n const configPath = upath.join(workDir, LocalConfigYaml);\n\n logger.info(`writing configuration '${configPath}'...`);\n await fsp.writeFile(configPath, ops.config);\n\n const plBinPath = upath.join(workDir, \"binaries\");\n const baseBinaryPath = await resolveLocalPlBinaryPath({\n logger,\n downloadDir: plBinPath,\n src: ops.plBinary,\n dispatcher: defaultHttpDispatcher(ops.proxy),\n });\n const binaryPath = trace(\"binaryPath\", upath.join(\"binaries\", baseBinaryPath));\n\n const env = { ...process.env };\n\n if (ops.proxy?.url) {\n const url = new URL(ops.proxy.url);\n if (ops.proxy.auth) {\n const parsed = parseHttpAuth(ops.proxy.auth);\n if (parsed.scheme !== \"Basic\") {\n throw new Error(`\\\nUnsupported auth scheme: ${parsed.scheme}. \\\nOnly Basic auth is supported by the backend.`);\n }\n url.username = parsed.username;\n url.password = parsed.password;\n }\n env.http_proxy = url.toString();\n env.https_proxy = url.toString();\n }\n\n const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);\n trace(\"processOpts\", {\n cmd: processOpts.cmd,\n args: processOpts.args,\n cwd: processOpts.opts.cwd,\n });\n\n const pl = new LocalPl(\n logger,\n ops.workingDir,\n processOpts,\n t,\n ops.onClose,\n ops.onError,\n ops.onCloseAndError,\n ops.onCloseAndErrorNoStop,\n );\n await pl.start();\n\n return pl;\n });\n}\n\n/** Reads a pid of the old pl-core if it was started in the same working directory,\n * and closes it. */\nasync function localPlatformaReadPidAndStop(\n logger: MiLogger,\n workingDir: string,\n): Promise<Record<string, any>> {\n return await withTrace(logger, async (trace, t) => {\n const file = trace(\"pidFilePath\", filePid(workingDir));\n\n const oldPid = trace(\"pid\", await readPid(file));\n const alive = trace(\"wasAlive\", await isProcessAlive(oldPid));\n\n if (oldPid !== undefined && alive) {\n trace(\"stopped\", processStop(oldPid));\n try {\n trace(\"waitStopped\", await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.\n } catch {\n trace(\"forceStopped\", processStop(oldPid, true));\n trace(\"waitForceStopped\", await processWaitStopped(oldPid, 5_000));\n }\n }\n\n return t;\n });\n}\n\n/** Gets default options for the whole init process\n * and overrides them with the provided options. */\nexport function mergeDefaultOps(ops: LocalPlOptions, numCpu: number): LocalPlOptionsFull {\n const result: {\n plBinary: PlBinarySource;\n spawnOptions: SpawnOptions;\n closeOld: boolean;\n } = {\n plBinary: newDefaultPlBinarySource(),\n spawnOptions: {\n env: {\n GOMAXPROCS: String(numCpu),\n },\n },\n closeOld: true,\n };\n\n if (ops.spawnOptions?.env) {\n result.spawnOptions.env = { ...result.spawnOptions.env, ...ops.spawnOptions.env };\n }\n\n if (ops.spawnOptions) {\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.spawnOptions = { ...result.spawnOptions, ...withoutEnv };\n }\n\n const withoutSpawnOps = { ...ops };\n delete withoutSpawnOps[\"spawnOptions\"];\n\n return { ...result, ...withoutSpawnOps };\n}\n\n/** Gets default options for a platforma local binary\n * and overrides them with the provided options. */\nexport function plProcessOps(\n binaryPath: any,\n configPath: string,\n ops: LocalPlOptionsFull,\n workDir: string,\n defaultEnv: Record<string, string | undefined>,\n): ProcessOptions {\n const result: ProcessOptions = {\n cmd: binaryPath,\n args: [\"--config\", configPath],\n opts: {\n env: { ...defaultEnv },\n cwd: workDir,\n stdio: [\"pipe\", \"ignore\", \"inherit\"],\n windowsHide: true, // hide a terminal on Windows\n },\n };\n\n if (ops.spawnOptions?.env) {\n result.opts.env = { ...result.opts.env, ...ops.spawnOptions.env };\n }\n\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.opts = { ...result.opts, ...withoutEnv };\n\n return result;\n}\n"],"names":["withTrace","processRun","filePid","notEmpty","writePid","processStop","processWaitStopped","isProcessAlive","os","resolveLocalPlBinaryPath","defaultHttpDispatcher","parseHttpAuth","readPid","newDef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,"file":"pl.cjs","names":["withTrace","processRun","filePid","writePid","processWaitStopped","isProcessAlive","os","fsp","resolveLocalPlBinaryPath","readPid","processStop","newDefaultPlBinarySource"],"sources":["../../src/local/pl.ts"],"sourcesContent":["import type { ProcessOptions } from \"./process\";\nimport { isProcessAlive, processStop, processWaitStopped, processRun } from \"./process\";\nimport type { PlBinarySource } from \"../common/pl_binary\";\nimport { newDefaultPlBinarySource, resolveLocalPlBinaryPath } from \"../common/pl_binary\";\nimport type { MiLogger } from \"@milaboratories/ts-helpers\";\nimport { notEmpty } from \"@milaboratories/ts-helpers\";\nimport type { ChildProcess, SpawnOptions } from \"node:child_process\";\nimport { filePid, readPid, writePid } from \"./pid\";\nimport type { Trace } from \"./trace\";\nimport { withTrace } from \"./trace\";\nimport upath from \"upath\";\nimport fsp from \"node:fs/promises\";\nimport type { Required } from \"utility-types\";\nimport * as os from \"node:os\";\nimport type { ProxySettings } from \"@milaboratories/pl-http\";\nimport { defaultHttpDispatcher } from \"@milaboratories/pl-http\";\nimport { parseHttpAuth } from \"@milaboratories/pl-model-common\";\n\nexport const LocalConfigYaml = \"config-local.yaml\";\n\n/**\n * Represents a local running pl-core,\n * and has methods to start, check if it's running, stop and wait for stopping it.\n * Also, a hook on pl-core closed can be provided.\n */\nexport class LocalPl {\n private instance?: ChildProcess;\n public pid?: number;\n private nRuns: number = 0;\n private lastRunHistory: Trace = {};\n private wasStopped = false;\n\n constructor(\n private readonly logger: MiLogger,\n private readonly workingDir: string,\n private readonly startOptions: ProcessOptions,\n private readonly initialStartHistory: Trace,\n private readonly onClose?: (pl: LocalPl) => Promise<void>,\n private readonly onError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndError?: (pl: LocalPl) => Promise<void>,\n private readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>,\n ) {}\n\n async start() {\n await withTrace(this.logger, async (trace, t) => {\n this.wasStopped = false;\n const instance = processRun(this.logger, this.startOptions);\n instance.on(\"error\", (e: any) => {\n this.logger.error(\n `error '${e}', while running platforma, started opts: ${JSON.stringify(this.debugInfo())}`,\n );\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onError !== undefined) void this.onError(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n instance.on(\"close\", () => {\n this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`);\n\n // keep in mind there are no awaits here, it will be asynchronous\n if (this.onClose !== undefined) void this.onClose(this);\n if (this.onCloseAndError !== undefined) void this.onCloseAndError(this);\n if (this.onCloseAndErrorNoStop !== undefined && !this.wasStopped)\n void this.onCloseAndErrorNoStop(this);\n });\n\n trace(\"started\", true);\n\n const pidFile = trace(\"pidFile\", filePid(this.workingDir));\n trace(\"pid\", notEmpty(instance.pid));\n trace(\"pidWritten\", await writePid(pidFile, notEmpty(instance.pid)));\n\n this.nRuns++;\n this.instance = instance;\n this.pid = instance.pid;\n this.lastRunHistory = t;\n });\n }\n\n stop() {\n // TODO use this.instance to stop the process\n this.wasStopped = true;\n processStop(notEmpty(this.pid));\n }\n\n async waitStopped() {\n await processWaitStopped(notEmpty(this.pid), 15000);\n }\n\n stopped() {\n return this.wasStopped;\n }\n\n async isAlive(): Promise<boolean> {\n return await isProcessAlive(notEmpty(this.pid));\n }\n\n debugInfo() {\n return {\n lastRunHistory: this.lastRunHistory,\n nRuns: this.nRuns,\n pid: this.pid,\n workingDir: this.workingDir,\n initialStartHistory: this.initialStartHistory,\n wasStopped: this.wasStopped,\n };\n }\n}\n\n/** Options to start a local pl-core. */\nexport type LocalPlOptions = {\n /** From what directory start a process. */\n readonly workingDir: string;\n /** A string representation of yaml config. */\n readonly config: string;\n /** How to get a binary, download it or get an existing one (default: download latest version) */\n readonly plBinary?: PlBinarySource;\n /** Additional options for a process, environments, stdout, stderr etc. */\n readonly spawnOptions?: SpawnOptions;\n /**\n * If the previous pl-core was started from the same directory,\n * we can check if it's still running and then stop it before starting a new one.\n * (default: true)\n */\n readonly closeOld?: boolean;\n /**\n * Proxy settings to use to fetch the binary and pass it down\n * as a HTTPS_PROXY/HTTP_PROXY environment variable;\n * Backend only supports Basic auth.\n */\n readonly proxy?: ProxySettings;\n\n readonly onClose?: (pl: LocalPl) => Promise<void>;\n readonly onError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndError?: (pl: LocalPl) => Promise<void>;\n readonly onCloseAndErrorNoStop?: (pl: LocalPl) => Promise<void>;\n};\n\nexport type LocalPlOptionsFull = Required<LocalPlOptions, \"plBinary\" | \"spawnOptions\" | \"closeOld\">;\n\n/**\n * Starts pl-core, if the option was provided downloads a binary, reads license environments etc.\n */\nexport async function localPlatformaInit(logger: MiLogger, _ops: LocalPlOptions): Promise<LocalPl> {\n // filling-in default values\n\n // Backend could consume a lot of CPU power,\n // we want to keep at least a couple for UI and other apps to work.\n const numCpu = Math.max(os.cpus().length - 2, 1);\n const ops = mergeDefaultOps(_ops, numCpu);\n\n return await withTrace(logger, async (trace, t) => {\n trace(\"startOptions\", { ...ops, config: \"too wordy\" });\n\n const workDir = upath.resolve(ops.workingDir);\n\n if (ops.closeOld) {\n trace(\"closeOld\", await localPlatformaReadPidAndStop(logger, workDir));\n }\n\n const configPath = upath.join(workDir, LocalConfigYaml);\n\n logger.info(`writing configuration '${configPath}'...`);\n await fsp.writeFile(configPath, ops.config);\n\n const plBinPath = upath.join(workDir, \"binaries\");\n const baseBinaryPath = await resolveLocalPlBinaryPath({\n logger,\n downloadDir: plBinPath,\n src: ops.plBinary,\n dispatcher: defaultHttpDispatcher(ops.proxy),\n });\n const binaryPath = trace(\"binaryPath\", upath.join(\"binaries\", baseBinaryPath));\n\n const env = { ...process.env };\n\n if (ops.proxy?.url) {\n const url = new URL(ops.proxy.url);\n if (ops.proxy.auth) {\n const parsed = parseHttpAuth(ops.proxy.auth);\n if (parsed.scheme !== \"Basic\") {\n throw new Error(`\\\nUnsupported auth scheme: ${parsed.scheme}. \\\nOnly Basic auth is supported by the backend.`);\n }\n url.username = parsed.username;\n url.password = parsed.password;\n }\n env.http_proxy = url.toString();\n env.https_proxy = url.toString();\n }\n\n const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);\n trace(\"processOpts\", {\n cmd: processOpts.cmd,\n args: processOpts.args,\n cwd: processOpts.opts.cwd,\n });\n\n const pl = new LocalPl(\n logger,\n ops.workingDir,\n processOpts,\n t,\n ops.onClose,\n ops.onError,\n ops.onCloseAndError,\n ops.onCloseAndErrorNoStop,\n );\n await pl.start();\n\n return pl;\n });\n}\n\n/** Reads a pid of the old pl-core if it was started in the same working directory,\n * and closes it. */\nasync function localPlatformaReadPidAndStop(\n logger: MiLogger,\n workingDir: string,\n): Promise<Record<string, any>> {\n return await withTrace(logger, async (trace, t) => {\n const file = trace(\"pidFilePath\", filePid(workingDir));\n\n const oldPid = trace(\"pid\", await readPid(file));\n const alive = trace(\"wasAlive\", await isProcessAlive(oldPid));\n\n if (oldPid !== undefined && alive) {\n trace(\"stopped\", processStop(oldPid));\n try {\n trace(\"waitStopped\", await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.\n } catch {\n trace(\"forceStopped\", processStop(oldPid, true));\n trace(\"waitForceStopped\", await processWaitStopped(oldPid, 5_000));\n }\n }\n\n return t;\n });\n}\n\n/** Gets default options for the whole init process\n * and overrides them with the provided options. */\nexport function mergeDefaultOps(ops: LocalPlOptions, numCpu: number): LocalPlOptionsFull {\n const result: {\n plBinary: PlBinarySource;\n spawnOptions: SpawnOptions;\n closeOld: boolean;\n } = {\n plBinary: newDefaultPlBinarySource(),\n spawnOptions: {\n env: {\n GOMAXPROCS: String(numCpu),\n },\n },\n closeOld: true,\n };\n\n if (ops.spawnOptions?.env) {\n result.spawnOptions.env = { ...result.spawnOptions.env, ...ops.spawnOptions.env };\n }\n\n if (ops.spawnOptions) {\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.spawnOptions = { ...result.spawnOptions, ...withoutEnv };\n }\n\n const withoutSpawnOps = { ...ops };\n delete withoutSpawnOps[\"spawnOptions\"];\n\n return { ...result, ...withoutSpawnOps };\n}\n\n/** Gets default options for a platforma local binary\n * and overrides them with the provided options. */\nexport function plProcessOps(\n binaryPath: any,\n configPath: string,\n ops: LocalPlOptionsFull,\n workDir: string,\n defaultEnv: Record<string, string | undefined>,\n): ProcessOptions {\n const result: ProcessOptions = {\n cmd: binaryPath,\n args: [\"--config\", configPath],\n opts: {\n env: { ...defaultEnv },\n cwd: workDir,\n stdio: [\"pipe\", \"ignore\", \"inherit\"],\n windowsHide: true, // hide a terminal on Windows\n },\n };\n\n if (ops.spawnOptions?.env) {\n result.opts.env = { ...result.opts.env, ...ops.spawnOptions.env };\n }\n\n const withoutEnv = { ...ops.spawnOptions };\n delete withoutEnv[\"env\"];\n result.opts = { ...result.opts, ...withoutEnv };\n\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAa,kBAAkB;;;;;;AAO/B,IAAa,UAAb,MAAqB;CACnB,AAAQ;CACR,AAAO;CACP,AAAQ,QAAgB;CACxB,AAAQ,iBAAwB,EAAE;CAClC,AAAQ,aAAa;CAErB,YACE,AAAiB,QACjB,AAAiB,YACjB,AAAiB,cACjB,AAAiB,qBACjB,AAAiB,SACjB,AAAiB,SACjB,AAAiB,iBACjB,AAAiB,uBACjB;EARiB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;CAGnB,MAAM,QAAQ;AACZ,QAAMA,wBAAU,KAAK,QAAQ,OAAO,OAAO,MAAM;AAC/C,QAAK,aAAa;GAClB,MAAM,WAAWC,2BAAW,KAAK,QAAQ,KAAK,aAAa;AAC3D,YAAS,GAAG,UAAU,MAAW;AAC/B,SAAK,OAAO,MACV,UAAU,EAAE,4CAA4C,KAAK,UAAU,KAAK,WAAW,CAAC,GACzF;AAGD,QAAI,KAAK,YAAY,OAAW,CAAK,KAAK,QAAQ,KAAK;AACvD,QA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