@milaboratories/pl-deployments 1.1.13 → 1.1.15
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/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -108
- package/dist/index.mjs.map +1 -1
- package/dist/ssh/connection_info.d.ts +4 -1
- package/dist/ssh/connection_info.d.ts.map +1 -1
- package/dist/ssh/pl.d.ts +8 -4
- package/dist/ssh/pl.d.ts.map +1 -1
- package/dist/ssh/pl_paths.d.ts.map +1 -1
- package/dist/ssh/ssh.d.ts +1 -1
- package/dist/ssh/ssh.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ssh/__tests__/pl-docker.test.ts +24 -1
- package/src/ssh/__tests__/ssh-docker.test.ts +7 -7
- package/src/ssh/connection_info.ts +5 -0
- package/src/ssh/pl.ts +33 -17
- package/src/ssh/pl_paths.ts +1 -1
- package/src/ssh/ssh.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Y = (s, r, t) => r in s ?
|
|
1
|
+
var Z = Object.defineProperty;
|
|
2
|
+
var Y = (s, r, t) => r in s ? Z(s, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[r] = t;
|
|
3
3
|
var w = (s, r, t) => Y(s, typeof r != "symbol" ? r + "" : r, t);
|
|
4
4
|
import { spawn as Q } from "node:child_process";
|
|
5
|
-
import { sleep as b, fileExists as
|
|
5
|
+
import { sleep as b, fileExists as y, assertNever as j, notEmpty as f, RetryablePromise as X } from "@milaboratories/ts-helpers";
|
|
6
6
|
import D from "node:fs";
|
|
7
7
|
import m, { readFile as tt } from "node:fs/promises";
|
|
8
8
|
import d from "upath";
|
|
@@ -16,7 +16,7 @@ import at, { Client as F } from "ssh2";
|
|
|
16
16
|
import H from "node:net";
|
|
17
17
|
import ct from "node:dns";
|
|
18
18
|
import { randomBytes as k } from "node:crypto";
|
|
19
|
-
import { generateSshPlConfigs as lt, getFreePort as
|
|
19
|
+
import { generateSshPlConfigs as lt, getFreePort as v } from "@milaboratories/pl-config";
|
|
20
20
|
import { z as p } from "zod";
|
|
21
21
|
function ht(s, r) {
|
|
22
22
|
return s.info(`Running:
|
|
@@ -72,7 +72,7 @@ function S(s) {
|
|
|
72
72
|
}
|
|
73
73
|
const wt = "https://cdn.platforma.bio/software", ft = "https://cdn-ga.pl-open.science/software";
|
|
74
74
|
async function pt(s, r, t, e, i, o) {
|
|
75
|
-
const n =
|
|
75
|
+
const n = G(t, e, r, S(i), O(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l } = n;
|
|
76
76
|
try {
|
|
77
77
|
await C(s, c, l), n.wasDownloadedFrom = c;
|
|
78
78
|
} catch {
|
|
@@ -81,7 +81,7 @@ async function pt(s, r, t, e, i, o) {
|
|
|
81
81
|
return n;
|
|
82
82
|
}
|
|
83
83
|
async function mt(s, r, t, e, i, o) {
|
|
84
|
-
const n =
|
|
84
|
+
const n = G(t, e, r, S(i), O(o)), { archiveUrl: c, alternativeArchiveGAUrl: a, archivePath: l, archiveType: h, targetFolder: u, baseName: $ } = n;
|
|
85
85
|
try {
|
|
86
86
|
await C(s, c, l), n.wasDownloadedFrom = c;
|
|
87
87
|
} catch {
|
|
@@ -89,7 +89,7 @@ async function mt(s, r, t, e, i, o) {
|
|
|
89
89
|
}
|
|
90
90
|
return await yt(s, l, h, u), n;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
92
|
+
function G(s, r, t, e, i) {
|
|
93
93
|
const o = `${r}-${e}`, n = $t[i], c = `${o}.${n}`, a = `${wt}/${s}/${i}/${c}`, l = `${ft}/${s}/${i}/${c}`, h = d.join(t, c), u = d.join(t, o);
|
|
94
94
|
return {
|
|
95
95
|
archiveUrl: a,
|
|
@@ -104,7 +104,7 @@ async function C(s, r, t) {
|
|
|
104
104
|
const e = {};
|
|
105
105
|
e.dstArchive = t;
|
|
106
106
|
try {
|
|
107
|
-
if (e.fileExisted = await
|
|
107
|
+
if (e.fileExisted = await y(t), e.fileExisted)
|
|
108
108
|
return s.info(`Platforma Backend archive download skipped: '${t}' already exists`), e;
|
|
109
109
|
await m.mkdir(d.dirname(t), { recursive: !0 }), e.dirnameCreated = !0, s.info(`Downloading archive:
|
|
110
110
|
URL: ${r}
|
|
@@ -114,7 +114,7 @@ async function C(s, r, t) {
|
|
|
114
114
|
const n = await ot(i);
|
|
115
115
|
throw e.errorMsg = `failed to download archive: ${o}, response: ${n.slice(0, 1e3)}`, s.error(e.errorMsg), new Error(e.errorMsg);
|
|
116
116
|
}
|
|
117
|
-
return e.tmpPath = t + ".tmp", await et.toWeb(i).pipeTo(it.toWeb(D.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await
|
|
117
|
+
return e.tmpPath = t + ".tmp", await et.toWeb(i).pipeTo(it.toWeb(D.createWriteStream(e.tmpPath))), e.wroteTmp = !0, e.tmpExisted = await y(e.tmpPath), await m.rename(e.tmpPath, t), e.renamed = !0, e.newExisted = await y(t), e;
|
|
118
118
|
} catch (i) {
|
|
119
119
|
const o = `downloadArchive: error ${JSON.stringify(i)} occurred, state: ${JSON.stringify(e)}`;
|
|
120
120
|
throw s.error(o), new Error(o);
|
|
@@ -122,16 +122,16 @@ async function C(s, r, t) {
|
|
|
122
122
|
}
|
|
123
123
|
const gt = ".ok";
|
|
124
124
|
async function yt(s, r, t, e) {
|
|
125
|
-
if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await
|
|
125
|
+
if (s.info("extracting archive..."), s.info(` archive path: '${r}'`), s.info(` target dir: '${e}'`), !await y(r)) {
|
|
126
126
|
const o = `Platforma Backend binary archive not found at '${r}'`;
|
|
127
127
|
throw s.error(o), new Error(o);
|
|
128
128
|
}
|
|
129
129
|
const i = d.join(e, gt);
|
|
130
|
-
if (await
|
|
130
|
+
if (await y(i)) {
|
|
131
131
|
s.info(`Platforma Backend binaries unpack skipped: '${e}' exists`);
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
switch (await
|
|
134
|
+
switch (await y(e) && (s.info(`Removing previous incompletely unpacked folder: '${e}'`), await m.rm(e, { recursive: !0 })), s.info(` creating target dir '${e}'`), await m.mkdir(e, { recursive: !0 }), s.info(
|
|
135
135
|
`Unpacking Platforma Backend archive:
|
|
136
136
|
Archive: ${r}
|
|
137
137
|
Target dir: ${e}`
|
|
@@ -159,10 +159,10 @@ const $t = {
|
|
|
159
159
|
function R() {
|
|
160
160
|
return "1.20.1";
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function vt() {
|
|
163
163
|
return { type: "Download", version: R() };
|
|
164
164
|
}
|
|
165
|
-
async function
|
|
165
|
+
async function Pt(s, r, t) {
|
|
166
166
|
switch (t.type) {
|
|
167
167
|
case "Download":
|
|
168
168
|
const e = await mt(s, r, "pl", `pl-${t.version}`, A.arch(), A.platform());
|
|
@@ -178,11 +178,11 @@ const St = {
|
|
|
178
178
|
macos: "platforma",
|
|
179
179
|
windows: "platforma.exe"
|
|
180
180
|
};
|
|
181
|
-
function
|
|
181
|
+
function L(s) {
|
|
182
182
|
return d.join(s, "pl_pid");
|
|
183
183
|
}
|
|
184
184
|
async function Ct(s) {
|
|
185
|
-
if (!await
|
|
185
|
+
if (!await y(s))
|
|
186
186
|
return;
|
|
187
187
|
const r = await m.readFile(s);
|
|
188
188
|
return Number(r.toString());
|
|
@@ -196,7 +196,7 @@ function At() {
|
|
|
196
196
|
function Ft(s, r, t) {
|
|
197
197
|
return s[r] = t, t;
|
|
198
198
|
}
|
|
199
|
-
async function
|
|
199
|
+
async function B(s, r) {
|
|
200
200
|
const t = At();
|
|
201
201
|
try {
|
|
202
202
|
return await r((i, o) => Ft(t, i, o), t);
|
|
@@ -215,7 +215,7 @@ class Dt {
|
|
|
215
215
|
this.logger = r, this.workingDir = t, this.startOptions = e, this.initialStartHistory = i, this.onClose = o, this.onError = n, this.onCloseAndError = c, this.onCloseAndErrorNoStop = a;
|
|
216
216
|
}
|
|
217
217
|
async start() {
|
|
218
|
-
await
|
|
218
|
+
await B(this.logger, async (r, t) => {
|
|
219
219
|
this.wasStopped = !1;
|
|
220
220
|
const e = ht(this.logger, this.startOptions);
|
|
221
221
|
e.on("error", (o) => {
|
|
@@ -225,7 +225,7 @@ class Dt {
|
|
|
225
225
|
}), e.on("close", () => {
|
|
226
226
|
this.logger.warn(`platforma was closed, started opts: ${JSON.stringify(this.debugInfo())}`), this.onClose !== void 0 && this.onClose(this), this.onCloseAndError !== void 0 && this.onCloseAndError(this), this.onCloseAndErrorNoStop !== void 0 && !this.wasStopped && this.onCloseAndErrorNoStop(this);
|
|
227
227
|
}), r("started", !0);
|
|
228
|
-
const i = r("pidFile",
|
|
228
|
+
const i = r("pidFile", L(this.workingDir));
|
|
229
229
|
r("pid", f(e.pid)), r("pidWritten", await Et(i, f(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = t;
|
|
230
230
|
});
|
|
231
231
|
}
|
|
@@ -254,18 +254,18 @@ class Dt {
|
|
|
254
254
|
}
|
|
255
255
|
async function fr(s, r) {
|
|
256
256
|
const t = {
|
|
257
|
-
plBinary:
|
|
257
|
+
plBinary: vt(),
|
|
258
258
|
spawnOptions: {},
|
|
259
259
|
closeOld: !0,
|
|
260
260
|
...r
|
|
261
261
|
};
|
|
262
|
-
return await
|
|
262
|
+
return await B(s, async (e, i) => {
|
|
263
263
|
e("startOptions", { ...t, config: "too wordy" });
|
|
264
264
|
const o = d.resolve(t.workingDir);
|
|
265
265
|
t.closeOld && e("closeOld", await kt(s, o));
|
|
266
266
|
const n = d.join(o, bt);
|
|
267
267
|
s.info(`writing configuration '${n}'...`), await m.writeFile(n, t.config);
|
|
268
|
-
const c = d.join(o, "binaries"), a = await
|
|
268
|
+
const c = d.join(o, "binaries"), a = await Pt(s, c, t.plBinary), h = {
|
|
269
269
|
cmd: e("binaryPath", d.join("binaries", a)),
|
|
270
270
|
args: ["-config", n],
|
|
271
271
|
opts: {
|
|
@@ -296,8 +296,8 @@ async function fr(s, r) {
|
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
async function kt(s, r) {
|
|
299
|
-
return await
|
|
300
|
-
const i = t("pidFilePath",
|
|
299
|
+
return await B(s, async (t, e) => {
|
|
300
|
+
const i = t("pidFilePath", L(r)), o = t("pid", await Ct(i)), n = t("wasAlive", await x(o));
|
|
301
301
|
return o !== void 0 && n && (t("stopped", J(o)), t("waitStopped", await M(o, 1e4))), e;
|
|
302
302
|
});
|
|
303
303
|
}
|
|
@@ -305,7 +305,7 @@ const xt = {
|
|
|
305
305
|
keepaliveInterval: 6e4,
|
|
306
306
|
keepaliveCountMax: 10
|
|
307
307
|
};
|
|
308
|
-
class
|
|
308
|
+
class N {
|
|
309
309
|
constructor(r, t) {
|
|
310
310
|
w(this, "config");
|
|
311
311
|
w(this, "homeDir");
|
|
@@ -321,7 +321,7 @@ class U {
|
|
|
321
321
|
const e = {
|
|
322
322
|
...xt,
|
|
323
323
|
...t
|
|
324
|
-
}, i = new
|
|
324
|
+
}, i = new N(r, new F());
|
|
325
325
|
return await i.connect(e), i;
|
|
326
326
|
}
|
|
327
327
|
getForwardedServers() {
|
|
@@ -426,19 +426,19 @@ class U {
|
|
|
426
426
|
let h;
|
|
427
427
|
try {
|
|
428
428
|
h = await i.ensure();
|
|
429
|
-
} catch (
|
|
430
|
-
this.logger.info(`${l}.persistentClient.catch: ${
|
|
429
|
+
} catch ($) {
|
|
430
|
+
this.logger.info(`${l}.persistentClient.catch: ${$}`), a.end();
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
let u;
|
|
434
434
|
try {
|
|
435
435
|
u = await Rt(this.logger, h, "127.0.0.1", 0, "127.0.0.1", r.remotePort);
|
|
436
|
-
} catch (
|
|
437
|
-
this.logger.error(`${l}.forwardOut.err: ${
|
|
436
|
+
} catch ($) {
|
|
437
|
+
this.logger.error(`${l}.forwardOut.err: ${$}`), a.end();
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
|
-
a.pipe(u), u.pipe(a), a.resume(), u.on("error", (
|
|
441
|
-
this.logger.error(`${l}.stream.error: ${
|
|
440
|
+
a.pipe(u), u.pipe(a), a.resume(), u.on("error", ($) => {
|
|
441
|
+
this.logger.error(`${l}.stream.error: ${$}`), a.end(), u.end();
|
|
442
442
|
}), u.on("close", () => {
|
|
443
443
|
a.end(), u.end();
|
|
444
444
|
}), a.on("close", () => {
|
|
@@ -698,7 +698,7 @@ class U {
|
|
|
698
698
|
* @param remotePath - The path to the remote directory.
|
|
699
699
|
* @returns A promise that resolves when the directory is created.
|
|
700
700
|
*/
|
|
701
|
-
|
|
701
|
+
ensureRemoteDirCreated(r, t = 493) {
|
|
702
702
|
return this.withSftp(async (e) => {
|
|
703
703
|
const i = r.split("/");
|
|
704
704
|
let o = "";
|
|
@@ -758,12 +758,12 @@ async function Rt(s, r, t, e, i, o) {
|
|
|
758
758
|
r.forwardOut(t, e, i, o, (a, l) => a ? (s.error(`forwardOut.error: ${a}`), c(a)) : n(l));
|
|
759
759
|
});
|
|
760
760
|
}
|
|
761
|
-
const
|
|
762
|
-
function
|
|
761
|
+
const Bt = "minio-2024-12-18T13-15-44Z", Nt = "supervisord-0.7.3", Ut = "supervisord_0.7.3_Linux_64-bit";
|
|
762
|
+
function g(s) {
|
|
763
763
|
return d.join(s, ".platforma_ssh");
|
|
764
764
|
}
|
|
765
765
|
function E(s) {
|
|
766
|
-
return d.join(
|
|
766
|
+
return d.join(g(s), "binaries");
|
|
767
767
|
}
|
|
768
768
|
function Tt(s, r) {
|
|
769
769
|
return d.join(E(s), `pl-${R()}-${S(r)}`);
|
|
@@ -784,31 +784,31 @@ function _t(s, r) {
|
|
|
784
784
|
return d.join(z(s, r), "minio");
|
|
785
785
|
}
|
|
786
786
|
function jt(s, r) {
|
|
787
|
-
return d.join(E(s), `supervisord-0.7.3-${S(r)}`,
|
|
787
|
+
return d.join(E(s), `supervisord-0.7.3-${S(r)}`, Ut);
|
|
788
788
|
}
|
|
789
789
|
function K(s, r) {
|
|
790
790
|
return d.join(jt(s, r), "supervisord");
|
|
791
791
|
}
|
|
792
|
-
function
|
|
793
|
-
return d.join(
|
|
792
|
+
function V(s) {
|
|
793
|
+
return d.join(g(s), "supervisor.conf");
|
|
794
794
|
}
|
|
795
795
|
function I(s) {
|
|
796
|
-
return d.join(
|
|
796
|
+
return d.join(g(s), "connection.txt");
|
|
797
797
|
}
|
|
798
798
|
async function Ht(s, r, t) {
|
|
799
|
-
const e = await
|
|
799
|
+
const e = await U(s, r, t, "--daemon");
|
|
800
800
|
if (e.stderr)
|
|
801
801
|
throw new Error(`Can not run ssh Platforma ${e.stderr}`);
|
|
802
802
|
}
|
|
803
803
|
async function Jt(s, r, t) {
|
|
804
|
-
const e = await
|
|
804
|
+
const e = await U(s, r, t, "ctl shutdown");
|
|
805
805
|
if (e.stderr)
|
|
806
806
|
throw new Error(`Can not stop ssh Platforma ${e.stderr}`);
|
|
807
807
|
}
|
|
808
808
|
async function Mt(s, r, t, e) {
|
|
809
809
|
let i;
|
|
810
810
|
try {
|
|
811
|
-
i = await
|
|
811
|
+
i = await U(r, t, e, "ctl status");
|
|
812
812
|
} catch (a) {
|
|
813
813
|
return { execError: String(a), allAlive: !1 };
|
|
814
814
|
}
|
|
@@ -822,7 +822,7 @@ async function Mt(s, r, t, e) {
|
|
|
822
822
|
};
|
|
823
823
|
return c.allAlive || (c.minio || s.warn("Minio is not running on the server"), c.platforma || s.warn("Platforma is not running on the server")), c;
|
|
824
824
|
}
|
|
825
|
-
function
|
|
825
|
+
function Gt(s, r, t, e, i, o, n) {
|
|
826
826
|
const c = Object.entries(r).map(([h, u]) => `${h}="${u}"`).join(","), a = k(16).toString("hex"), l = t;
|
|
827
827
|
return `
|
|
828
828
|
[supervisord]
|
|
@@ -855,8 +855,8 @@ directory=${e}
|
|
|
855
855
|
autorestart=true
|
|
856
856
|
`;
|
|
857
857
|
}
|
|
858
|
-
async function
|
|
859
|
-
const i = K(r, t), o =
|
|
858
|
+
async function U(s, r, t, e) {
|
|
859
|
+
const i = K(r, t), o = V(r), n = `${i} --configuration ${o} ${e}`;
|
|
860
860
|
return await s.exec(n);
|
|
861
861
|
}
|
|
862
862
|
function _(s, r) {
|
|
@@ -866,38 +866,41 @@ function _(s, r) {
|
|
|
866
866
|
return o === r && n === "Running";
|
|
867
867
|
});
|
|
868
868
|
}
|
|
869
|
-
const
|
|
869
|
+
const P = p.object({
|
|
870
870
|
local: p.number(),
|
|
871
871
|
remote: p.number()
|
|
872
|
-
}),
|
|
873
|
-
grpc:
|
|
874
|
-
monitoring:
|
|
875
|
-
debug:
|
|
876
|
-
minioPort:
|
|
877
|
-
minioConsolePort:
|
|
872
|
+
}), Lt = p.object({
|
|
873
|
+
grpc: P,
|
|
874
|
+
monitoring: P,
|
|
875
|
+
debug: P,
|
|
876
|
+
minioPort: P,
|
|
877
|
+
minioConsolePort: P
|
|
878
878
|
}), Wt = p.object({
|
|
879
879
|
plUser: p.string(),
|
|
880
880
|
plPassword: p.string(),
|
|
881
|
-
ports:
|
|
881
|
+
ports: Lt,
|
|
882
882
|
// It's false by default because it was added later,
|
|
883
883
|
// and in some deployments there won't be useGlobalAccess flag in the file.
|
|
884
|
-
useGlobalAccess: p.boolean().default(!1)
|
|
884
|
+
useGlobalAccess: p.boolean().default(!1),
|
|
885
|
+
// We added the field afterwards, the pl backend was this version.
|
|
886
|
+
plVersion: p.string().default("1.18.3")
|
|
885
887
|
});
|
|
886
|
-
function zt(s, r, t, e) {
|
|
888
|
+
function zt(s, r, t, e, i) {
|
|
887
889
|
return {
|
|
888
890
|
plUser: s,
|
|
889
891
|
plPassword: r,
|
|
890
892
|
ports: t,
|
|
891
|
-
useGlobalAccess: e
|
|
893
|
+
useGlobalAccess: e,
|
|
894
|
+
plVersion: i
|
|
892
895
|
};
|
|
893
896
|
}
|
|
894
897
|
function Kt(s) {
|
|
895
898
|
return Wt.parse(JSON.parse(s));
|
|
896
899
|
}
|
|
897
|
-
function
|
|
900
|
+
function Vt(s) {
|
|
898
901
|
return JSON.stringify(s, void 0, 2);
|
|
899
902
|
}
|
|
900
|
-
class
|
|
903
|
+
class q {
|
|
901
904
|
constructor(r, t, e) {
|
|
902
905
|
w(this, "initState", {});
|
|
903
906
|
this.logger = r, this.sshClient = t, this.username = e;
|
|
@@ -910,8 +913,8 @@ class Z {
|
|
|
910
913
|
}
|
|
911
914
|
static async init(r, t) {
|
|
912
915
|
try {
|
|
913
|
-
const e = await
|
|
914
|
-
return new
|
|
916
|
+
const e = await N.init(r, t);
|
|
917
|
+
return new q(r, e, f(t.username));
|
|
915
918
|
} catch (e) {
|
|
916
919
|
throw r.error(`Connection error in SshClient.init: ${e}`), e;
|
|
917
920
|
}
|
|
@@ -955,7 +958,7 @@ class Z {
|
|
|
955
958
|
/** Stops platforma and deletes its state. */
|
|
956
959
|
async stopAndClean() {
|
|
957
960
|
const r = await this.getUserHomeDirectory();
|
|
958
|
-
this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${r} on the server`), await this.sshClient.deleteFolder(
|
|
961
|
+
this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${g(r)} on the server`), await this.sshClient.deleteFolder(g(r));
|
|
959
962
|
}
|
|
960
963
|
/** Downloads binaries and untar them on the server,
|
|
961
964
|
* generates all the configs, creates necessary dirs,
|
|
@@ -964,18 +967,20 @@ class Z {
|
|
|
964
967
|
const t = { localWorkdir: r.localWorkdir };
|
|
965
968
|
try {
|
|
966
969
|
const e = {
|
|
967
|
-
...
|
|
970
|
+
...qt,
|
|
968
971
|
...r
|
|
969
972
|
};
|
|
970
|
-
if (t.arch = await this.getArch(), t.remoteHome = await this.getUserHomeDirectory(), t.alive = await this.isAlive(), t.alive.allAlive) {
|
|
973
|
+
if (t.plBinaryOps = e.plBinary, t.arch = await this.getArch(), t.remoteHome = await this.getUserHomeDirectory(), t.alive = await this.isAlive(), t.alive.allAlive) {
|
|
971
974
|
if (t.userCredentials = await this.getUserCredentials(t.remoteHome), !t.userCredentials)
|
|
972
975
|
throw new Error("SshPl.platformaInit: platforma is alive but userCredentials are not found");
|
|
973
|
-
|
|
976
|
+
const a = t.userCredentials.useGlobalAccess == e.useGlobalAccess, l = t.userCredentials.plVersion == e.plBinary.version;
|
|
977
|
+
if (t.needRestart = !(a && l), this.logger.info(`SshPl.platformaInit: need restart? ${t.needRestart}`), !t.needRestart)
|
|
974
978
|
return t.userCredentials;
|
|
975
|
-
await this.
|
|
979
|
+
await this.stop();
|
|
976
980
|
}
|
|
977
981
|
const i = await this.downloadBinariesAndUploadToTheServer(
|
|
978
982
|
e.localWorkdir,
|
|
983
|
+
e.plBinary,
|
|
979
984
|
t.remoteHome,
|
|
980
985
|
t.arch
|
|
981
986
|
);
|
|
@@ -983,7 +988,7 @@ class Z {
|
|
|
983
988
|
throw new Error("SshPl.platformaInit: remote ports are not defined");
|
|
984
989
|
const o = await lt({
|
|
985
990
|
logger: this.logger,
|
|
986
|
-
workingDir:
|
|
991
|
+
workingDir: g(t.remoteHome),
|
|
987
992
|
portsMode: {
|
|
988
993
|
type: "customWithMinio",
|
|
989
994
|
ports: {
|
|
@@ -1003,8 +1008,8 @@ class Z {
|
|
|
1003
1008
|
for (const [a, l] of Object.entries(o.filesToCreate))
|
|
1004
1009
|
await this.sshClient.writeFileOnTheServer(a, l), this.logger.info(`Created file ${a}`);
|
|
1005
1010
|
for (const a of o.dirsToCreate)
|
|
1006
|
-
await this.sshClient.
|
|
1007
|
-
const n =
|
|
1011
|
+
await this.sshClient.ensureRemoteDirCreated(a), this.logger.info(`Created directory ${a}`);
|
|
1012
|
+
const n = Gt(
|
|
1008
1013
|
o.minioConfig.storageDir,
|
|
1009
1014
|
o.minioConfig.envs,
|
|
1010
1015
|
await this.getFreePortForPlatformaOnServer(t.remoteHome, t.arch),
|
|
@@ -1013,56 +1018,57 @@ class Z {
|
|
|
1013
1018
|
t.binPaths.minioRelPath,
|
|
1014
1019
|
t.binPaths.downloadedPl
|
|
1015
1020
|
);
|
|
1016
|
-
if (!await this.sshClient.writeFileOnTheServer(
|
|
1017
|
-
throw new Error(`Can not write supervisord config on the server ${
|
|
1021
|
+
if (!await this.sshClient.writeFileOnTheServer(V(t.remoteHome), n))
|
|
1022
|
+
throw new Error(`Can not write supervisord config on the server ${g(t.remoteHome)}`);
|
|
1018
1023
|
return t.connectionInfo = zt(
|
|
1019
1024
|
o.plUser,
|
|
1020
1025
|
o.plPassword,
|
|
1021
1026
|
t.ports,
|
|
1022
|
-
f(e.useGlobalAccess)
|
|
1027
|
+
f(e.useGlobalAccess),
|
|
1028
|
+
e.plBinary.version
|
|
1023
1029
|
), await this.sshClient.writeFileOnTheServer(
|
|
1024
1030
|
I(t.remoteHome),
|
|
1025
|
-
|
|
1031
|
+
Vt(t.connectionInfo)
|
|
1026
1032
|
), await this.start(), t.started = !0, this.initState = t, t.connectionInfo;
|
|
1027
1033
|
} catch (e) {
|
|
1028
1034
|
const i = `SshPl.platformaInit: error occurred: ${e}, state: ${JSON.stringify(t)}`;
|
|
1029
1035
|
throw this.logger.error(i), new Error(i);
|
|
1030
1036
|
}
|
|
1031
1037
|
}
|
|
1032
|
-
async downloadBinariesAndUploadToTheServer(r, t, e) {
|
|
1033
|
-
const
|
|
1038
|
+
async downloadBinariesAndUploadToTheServer(r, t, e, i) {
|
|
1039
|
+
const o = [];
|
|
1034
1040
|
try {
|
|
1035
|
-
const
|
|
1041
|
+
const n = await this.downloadAndUntar(
|
|
1036
1042
|
r,
|
|
1037
|
-
t,
|
|
1038
1043
|
e,
|
|
1044
|
+
i,
|
|
1039
1045
|
"pl",
|
|
1040
|
-
`pl-${
|
|
1046
|
+
`pl-${t.version}`
|
|
1041
1047
|
);
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1048
|
+
o.push(n);
|
|
1049
|
+
const c = await this.downloadAndUntar(
|
|
1044
1050
|
r,
|
|
1045
|
-
t,
|
|
1046
1051
|
e,
|
|
1052
|
+
i,
|
|
1047
1053
|
"supervisord",
|
|
1048
|
-
|
|
1054
|
+
Nt
|
|
1049
1055
|
);
|
|
1050
|
-
|
|
1051
|
-
const
|
|
1056
|
+
o.push(c);
|
|
1057
|
+
const a = _t(e, i.arch), l = await this.downloadAndUntar(
|
|
1052
1058
|
r,
|
|
1053
|
-
t,
|
|
1054
1059
|
e,
|
|
1060
|
+
i,
|
|
1055
1061
|
"minio",
|
|
1056
|
-
|
|
1062
|
+
Bt
|
|
1057
1063
|
);
|
|
1058
|
-
return
|
|
1059
|
-
history:
|
|
1060
|
-
minioRelPath:
|
|
1061
|
-
downloadedPl: T(
|
|
1064
|
+
return o.push(l), await this.sshClient.chmod(a, 488), {
|
|
1065
|
+
history: o,
|
|
1066
|
+
minioRelPath: a,
|
|
1067
|
+
downloadedPl: T(e, i.arch)
|
|
1062
1068
|
};
|
|
1063
|
-
} catch (
|
|
1064
|
-
const
|
|
1065
|
-
throw this.logger.error(
|
|
1069
|
+
} catch (n) {
|
|
1070
|
+
const c = `SshPl.downloadBinariesAndUploadToServer: error ${n} occurred, state: ${JSON.stringify(o)}`;
|
|
1071
|
+
throw this.logger.error(c), n;
|
|
1066
1072
|
}
|
|
1067
1073
|
}
|
|
1068
1074
|
/** We have to extract pl in the remote server,
|
|
@@ -1073,7 +1079,7 @@ class Z {
|
|
|
1073
1079
|
* (it's not installed for Rocky Linux for example). */
|
|
1074
1080
|
async downloadAndUntar(r, t, e, i, o) {
|
|
1075
1081
|
const n = {};
|
|
1076
|
-
n.binBasePath = E(t), await this.sshClient.
|
|
1082
|
+
n.binBasePath = E(t), await this.sshClient.ensureRemoteDirCreated(n.binBasePath), n.binBasePathCreated = !0;
|
|
1077
1083
|
let c = null;
|
|
1078
1084
|
const a = 5;
|
|
1079
1085
|
for (let h = 1; h <= a; h++)
|
|
@@ -1091,13 +1097,13 @@ class Z {
|
|
|
1091
1097
|
if (await b(300), h == a)
|
|
1092
1098
|
throw new Error(`downloadAndUntar: ${a} attempts, last error: ${u}`);
|
|
1093
1099
|
}
|
|
1094
|
-
n.downloadResult = f(c), n.localArchivePath = d.resolve(n.downloadResult.archivePath), n.remoteDir = d.join(n.binBasePath, n.downloadResult.baseName), n.remoteArchivePath = n.remoteDir + ".tgz", await this.sshClient.
|
|
1100
|
+
n.downloadResult = f(c), n.localArchivePath = d.resolve(n.downloadResult.archivePath), n.remoteDir = d.join(n.binBasePath, n.downloadResult.baseName), n.remoteArchivePath = n.remoteDir + ".tgz", await this.sshClient.ensureRemoteDirCreated(n.remoteDir), await this.sshClient.uploadFile(n.localArchivePath, n.remoteArchivePath), n.uploadDone = !0;
|
|
1095
1101
|
const l = await this.sshClient.exec(
|
|
1096
1102
|
`tar --warning=no-all -xvf ${n.remoteArchivePath} --directory=${n.remoteDir}`
|
|
1097
1103
|
);
|
|
1098
1104
|
if (l.stderr)
|
|
1099
1105
|
throw Error(`downloadAndUntar: untar: stderr occurred: ${l.stderr}, stdout: ${l.stdout}`);
|
|
1100
|
-
return n.
|
|
1106
|
+
return n.untarDone = !0, n;
|
|
1101
1107
|
}
|
|
1102
1108
|
async needDownload(r, t) {
|
|
1103
1109
|
const e = K(r, t.arch), i = z(r, t.arch), o = T(r, t.arch);
|
|
@@ -1119,23 +1125,23 @@ class Z {
|
|
|
1119
1125
|
async fetchPorts(r, t) {
|
|
1120
1126
|
return {
|
|
1121
1127
|
grpc: {
|
|
1122
|
-
local: await
|
|
1128
|
+
local: await v(),
|
|
1123
1129
|
remote: await this.getFreePortForPlatformaOnServer(r, t)
|
|
1124
1130
|
},
|
|
1125
1131
|
monitoring: {
|
|
1126
|
-
local: await
|
|
1132
|
+
local: await v(),
|
|
1127
1133
|
remote: await this.getFreePortForPlatformaOnServer(r, t)
|
|
1128
1134
|
},
|
|
1129
1135
|
debug: {
|
|
1130
|
-
local: await
|
|
1136
|
+
local: await v(),
|
|
1131
1137
|
remote: await this.getFreePortForPlatformaOnServer(r, t)
|
|
1132
1138
|
},
|
|
1133
1139
|
minioPort: {
|
|
1134
|
-
local: await
|
|
1140
|
+
local: await v(),
|
|
1135
1141
|
remote: await this.getFreePortForPlatformaOnServer(r, t)
|
|
1136
1142
|
},
|
|
1137
1143
|
minioConsolePort: {
|
|
1138
|
-
local: await
|
|
1144
|
+
local: await v(),
|
|
1139
1145
|
remote: await this.getFreePortForPlatformaOnServer(r, t)
|
|
1140
1146
|
}
|
|
1141
1147
|
};
|
|
@@ -1175,21 +1181,25 @@ class Z {
|
|
|
1175
1181
|
return r.trim();
|
|
1176
1182
|
}
|
|
1177
1183
|
}
|
|
1178
|
-
const
|
|
1179
|
-
useGlobalAccess: !1
|
|
1184
|
+
const qt = {
|
|
1185
|
+
useGlobalAccess: !1,
|
|
1186
|
+
plBinary: {
|
|
1187
|
+
type: "Download",
|
|
1188
|
+
version: R()
|
|
1189
|
+
}
|
|
1180
1190
|
};
|
|
1181
1191
|
export {
|
|
1182
1192
|
Wt as ConnectionInfo,
|
|
1183
1193
|
bt as LocalConfigYaml,
|
|
1184
1194
|
Dt as LocalPl,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1195
|
+
P as PortPair,
|
|
1196
|
+
N as SshClient,
|
|
1197
|
+
q as SshPl,
|
|
1198
|
+
Lt as SshPlPorts,
|
|
1189
1199
|
R as getDefaultPlVersion,
|
|
1190
1200
|
fr as localPlatformaInit,
|
|
1191
1201
|
zt as newConnectionInfo,
|
|
1192
1202
|
Kt as parseConnectionInfo,
|
|
1193
|
-
|
|
1203
|
+
Vt as stringifyConnectionInfo
|
|
1194
1204
|
};
|
|
1195
1205
|
//# sourceMappingURL=index.mjs.map
|