@milaboratories/pl-deployments 1.7.0 → 1.7.1
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/common/os_and_arch.d.ts.map +1 -1
- package/dist/common/pl_binary.d.ts.map +1 -1
- package/dist/common/pl_binary_download.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -43
- package/dist/index.mjs.map +1 -1
- package/dist/local/options.d.ts +1 -1
- package/dist/local/options.d.ts.map +1 -1
- package/dist/local/pl.d.ts +1 -1
- package/dist/local/pl.d.ts.map +1 -1
- package/dist/local/process.d.ts +1 -1
- package/dist/local/process.d.ts.map +1 -1
- package/dist/ssh/pl.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 +8 -4
- package/src/common/os_and_arch.ts +0 -2
- package/src/common/pl_binary.ts +2 -1
- package/src/common/pl_binary_download.ts +8 -7
- package/src/local/options.ts +1 -1
- package/src/local/pid.ts +1 -1
- package/src/local/pl.ts +8 -8
- package/src/local/process.ts +4 -3
- package/src/ssh/__tests__/common-utils.ts +4 -4
- package/src/ssh/pl.ts +1 -2
- package/src/ssh/ssh.ts +12 -11
- package/src/ssh/supervisord.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import ct, { Client as b } from "ssh2";
|
|
|
16
16
|
import G from "node:net";
|
|
17
17
|
import lt from "node:dns";
|
|
18
18
|
import { randomBytes as k } from "node:crypto";
|
|
19
|
-
import { generateSshPlConfigs as ht, getFreePort as
|
|
19
|
+
import { generateSshPlConfigs as ht, getFreePort as $ } from "@milaboratories/pl-config";
|
|
20
20
|
import { z as p } from "zod";
|
|
21
21
|
function dt(n, e) {
|
|
22
22
|
return n.info(`Running:
|
|
@@ -81,16 +81,16 @@ async function mt(n, e, r, t, i, o) {
|
|
|
81
81
|
return s;
|
|
82
82
|
}
|
|
83
83
|
async function gt(n, e, r, t, i, o) {
|
|
84
|
-
const s = L(r, t, e, P(i), O(o)), { archiveUrl: a, alternativeArchiveGAUrl: c, archivePath: l, archiveType: h, targetFolder: d
|
|
84
|
+
const s = L(r, t, e, P(i), O(o)), { archiveUrl: a, alternativeArchiveGAUrl: c, archivePath: l, archiveType: h, targetFolder: d } = s;
|
|
85
85
|
try {
|
|
86
86
|
await C(n, a, l), s.wasDownloadedFrom = a;
|
|
87
87
|
} catch {
|
|
88
88
|
await C(n, c, l), s.wasDownloadedFrom = c;
|
|
89
89
|
}
|
|
90
|
-
return await
|
|
90
|
+
return await vt(n, l, h, d), s;
|
|
91
91
|
}
|
|
92
92
|
function L(n, e, r, t, i) {
|
|
93
|
-
const o = `${e}-${t}`, s =
|
|
93
|
+
const o = `${e}-${t}`, s = $t[i], a = `${o}.${s}`, c = `${ft}/${n}/${i}/${a}`, l = `${pt}/${n}/${i}/${a}`, h = u.join(r, a), d = u.join(r, o);
|
|
94
94
|
return {
|
|
95
95
|
archiveUrl: c,
|
|
96
96
|
alternativeArchiveGAUrl: l,
|
|
@@ -121,7 +121,7 @@ async function C(n, e, r) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
const yt = ".ok";
|
|
124
|
-
async function
|
|
124
|
+
async function vt(n, e, r, t) {
|
|
125
125
|
if (n.info("extracting archive..."), n.info(` archive path: '${e}'`), n.info(` target dir: '${t}'`), !await y(e)) {
|
|
126
126
|
const o = `Platforma Backend binary archive not found at '${e}'`;
|
|
127
127
|
throw n.error(o), new Error(o);
|
|
@@ -151,7 +151,7 @@ async function $t(n, e, r, t) {
|
|
|
151
151
|
}
|
|
152
152
|
await m.writeFile(i, "ok"), n.info(" ... unpack done.");
|
|
153
153
|
}
|
|
154
|
-
const
|
|
154
|
+
const $t = {
|
|
155
155
|
linux: "tgz",
|
|
156
156
|
macos: "tgz",
|
|
157
157
|
windows: "zip"
|
|
@@ -252,7 +252,7 @@ class kt {
|
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
async function
|
|
255
|
+
async function mr(n, e) {
|
|
256
256
|
const r = {
|
|
257
257
|
plBinary: St(),
|
|
258
258
|
spawnOptions: {},
|
|
@@ -352,7 +352,7 @@ class B {
|
|
|
352
352
|
return new Promise((r, t) => {
|
|
353
353
|
this.client.exec(e, (i, o) => {
|
|
354
354
|
if (i)
|
|
355
|
-
return t(`ssh.exec: ${e}: ${i}`);
|
|
355
|
+
return t(new Error(`ssh.exec: ${e}: ${i}`));
|
|
356
356
|
let s = "", a = "";
|
|
357
357
|
o.on("close", (c) => {
|
|
358
358
|
c === 0 ? r({ stdout: s, stderr: a }) : t(new Error(`Command ${e} exited with code ${c}, stdout: ${s}, stderr: ${a}`));
|
|
@@ -426,20 +426,20 @@ class B {
|
|
|
426
426
|
let h;
|
|
427
427
|
try {
|
|
428
428
|
h = await i.ensure();
|
|
429
|
-
} catch (
|
|
430
|
-
this.logger.info(`${l}.persistentClient.catch: ${
|
|
429
|
+
} catch (v) {
|
|
430
|
+
this.logger.info(`${l}.persistentClient.catch: ${v}`), c.end();
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
h.setNoDelay(!0), c.setNoDelay(!0);
|
|
434
434
|
let d;
|
|
435
435
|
try {
|
|
436
436
|
d = await Nt(this.logger, h, "127.0.0.1", 0, "127.0.0.1", e.remotePort);
|
|
437
|
-
} catch (
|
|
438
|
-
this.logger.error(`${l}.forwardOut.err: ${
|
|
437
|
+
} catch (v) {
|
|
438
|
+
this.logger.error(`${l}.forwardOut.err: ${v}`), c.end();
|
|
439
439
|
return;
|
|
440
440
|
}
|
|
441
|
-
c.pipe(d), d.pipe(c), c.resume(), d.on("error", (
|
|
442
|
-
this.logger.error(`${l}.stream.error: ${
|
|
441
|
+
c.pipe(d), d.pipe(c), c.resume(), d.on("error", (v) => {
|
|
442
|
+
this.logger.error(`${l}.stream.error: ${v}`), c.end(), d.end();
|
|
443
443
|
}), d.on("close", () => {
|
|
444
444
|
c.end(), d.end();
|
|
445
445
|
}), c.on("close", () => {
|
|
@@ -539,7 +539,7 @@ class B {
|
|
|
539
539
|
try {
|
|
540
540
|
await this.getForderStructure(e, l, t);
|
|
541
541
|
} catch (h) {
|
|
542
|
-
return o(h);
|
|
542
|
+
return o(h instanceof Error ? h : new Error(String(h)));
|
|
543
543
|
}
|
|
544
544
|
} else
|
|
545
545
|
t.files.push(l);
|
|
@@ -623,14 +623,12 @@ class B {
|
|
|
623
623
|
}
|
|
624
624
|
uploadFileUsingExistingSftp(e, r, t, i = 432) {
|
|
625
625
|
return new Promise((o, s) => {
|
|
626
|
-
rt(r).then(async (a) => {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
});
|
|
633
|
-
});
|
|
626
|
+
rt(r).then(async (a) => this.writeFile(e, t, a, i).then(() => {
|
|
627
|
+
o(void 0);
|
|
628
|
+
}).catch((c) => {
|
|
629
|
+
const l = `uploadFileUsingExistingSftp: ${c}`;
|
|
630
|
+
this.logger.error(l), s(new Error(l));
|
|
631
|
+
}));
|
|
634
632
|
});
|
|
635
633
|
}
|
|
636
634
|
async __uploadDirectory(e, r, t, i = 432) {
|
|
@@ -759,23 +757,23 @@ async function Nt(n, e, r, t, i, o) {
|
|
|
759
757
|
e.forwardOut(r, t, i, o, (c, l) => c ? (n.error(`forwardOut.error: ${c}`), a(c)) : s(l));
|
|
760
758
|
});
|
|
761
759
|
}
|
|
762
|
-
const Bt = "minio-2024-12-18T13-15-44Z", Ut = "supervisord-0.7.3",
|
|
760
|
+
const Bt = "minio-2024-12-18T13-15-44Z", Ut = "supervisord-0.7.3", _t = "supervisord_0.7.3_Linux_64-bit";
|
|
763
761
|
function g(n) {
|
|
764
762
|
return u.join(n, ".platforma_ssh");
|
|
765
763
|
}
|
|
766
764
|
function E(n) {
|
|
767
765
|
return u.join(g(n), "binaries");
|
|
768
766
|
}
|
|
769
|
-
function
|
|
767
|
+
function Tt(n, e) {
|
|
770
768
|
return u.join(E(n), `pl-${R()}-${P(e)}`);
|
|
771
769
|
}
|
|
772
770
|
function V(n, e) {
|
|
773
|
-
return u.join(
|
|
771
|
+
return u.join(Tt(n, e), "binaries");
|
|
774
772
|
}
|
|
775
|
-
function
|
|
773
|
+
function _(n, e) {
|
|
776
774
|
return u.join(V(n, e), "platforma");
|
|
777
775
|
}
|
|
778
|
-
function
|
|
776
|
+
function It(n, e) {
|
|
779
777
|
return u.join(V(n, e), "free-port");
|
|
780
778
|
}
|
|
781
779
|
function q(n, e) {
|
|
@@ -785,7 +783,7 @@ function jt(n, e) {
|
|
|
785
783
|
return u.join(q(n, e), "minio");
|
|
786
784
|
}
|
|
787
785
|
function Ht(n, e) {
|
|
788
|
-
return u.join(E(n), `supervisord-0.7.3-${P(e)}`,
|
|
786
|
+
return u.join(E(n), `supervisord-0.7.3-${P(e)}`, _t);
|
|
789
787
|
}
|
|
790
788
|
function z(n, e) {
|
|
791
789
|
return u.join(Ht(n, e), "supervisord");
|
|
@@ -793,7 +791,7 @@ function z(n, e) {
|
|
|
793
791
|
function K(n) {
|
|
794
792
|
return u.join(g(n), "supervisor.conf");
|
|
795
793
|
}
|
|
796
|
-
function
|
|
794
|
+
function T(n) {
|
|
797
795
|
return u.join(g(n), "connection.txt");
|
|
798
796
|
}
|
|
799
797
|
async function Gt(n, e, r) {
|
|
@@ -815,7 +813,7 @@ async function Jt(n, e, r, t) {
|
|
|
815
813
|
}
|
|
816
814
|
if (i.stderr)
|
|
817
815
|
return n.info(`supervisord ctl status: stderr occurred: ${i.stderr}, stdout: ${i.stdout}`), { rawResult: i, allAlive: !1 };
|
|
818
|
-
const o =
|
|
816
|
+
const o = I(i.stdout, "platforma"), s = I(i.stdout, "minio"), a = {
|
|
819
817
|
rawResult: i,
|
|
820
818
|
platforma: o,
|
|
821
819
|
minio: s,
|
|
@@ -860,7 +858,7 @@ async function U(n, e, r, t) {
|
|
|
860
858
|
const i = z(e, r), o = K(e), s = `${i} --configuration ${o} ${t}`;
|
|
861
859
|
return await n.exec(s);
|
|
862
860
|
}
|
|
863
|
-
function
|
|
861
|
+
function I(n, e) {
|
|
864
862
|
return ((i) => i.replace(/\x1B\[[0-9;]*m/g, ""))(n).split(`
|
|
865
863
|
`).some((i) => {
|
|
866
864
|
const [o, s] = i.trim().split(/\s{2,}/);
|
|
@@ -1036,7 +1034,7 @@ class Z {
|
|
|
1036
1034
|
f(i.useGlobalAccess),
|
|
1037
1035
|
i.plBinary.version
|
|
1038
1036
|
), await this.sshClient.writeFileOnTheServer(
|
|
1039
|
-
|
|
1037
|
+
T(r.remoteHome),
|
|
1040
1038
|
Kt(r.connectionInfo)
|
|
1041
1039
|
), await (t == null ? void 0 : t("Connection information saved.")), await (t == null ? void 0 : t("Starting Platforma on the server...")), await this.start(), r.started = !0, this.initState = r, await (t == null ? void 0 : t("Platforma has been started successfully.")), r.connectionInfo;
|
|
1042
1040
|
} catch (i) {
|
|
@@ -1073,7 +1071,7 @@ class Z {
|
|
|
1073
1071
|
return o.push(l), await this.sshClient.chmod(c, 488), {
|
|
1074
1072
|
history: o,
|
|
1075
1073
|
minioRelPath: c,
|
|
1076
|
-
downloadedPl:
|
|
1074
|
+
downloadedPl: _(t, i.arch)
|
|
1077
1075
|
};
|
|
1078
1076
|
} catch (s) {
|
|
1079
1077
|
const a = `SshPl.downloadBinariesAndUploadToServer: ${s}, state: ${JSON.stringify(o)}`;
|
|
@@ -1120,7 +1118,7 @@ class Z {
|
|
|
1120
1118
|
return s.untarDone = !0, s;
|
|
1121
1119
|
}
|
|
1122
1120
|
async needDownload(e, r) {
|
|
1123
|
-
const t = z(e, r.arch), i = q(e, r.arch), o =
|
|
1121
|
+
const t = z(e, r.arch), i = q(e, r.arch), o = _(e, r.arch);
|
|
1124
1122
|
return !await this.sshClient.checkFileExists(o) || !await this.sshClient.checkFileExists(i) || !await this.sshClient.checkFileExists(t);
|
|
1125
1123
|
}
|
|
1126
1124
|
async checkIsAliveWithInterval(e = 1e3, r = 15, t = !0) {
|
|
@@ -1133,29 +1131,29 @@ class Z {
|
|
|
1133
1131
|
}
|
|
1134
1132
|
}
|
|
1135
1133
|
async getUserCredentials(e) {
|
|
1136
|
-
const r = await this.sshClient.readFile(
|
|
1134
|
+
const r = await this.sshClient.readFile(T(e));
|
|
1137
1135
|
return zt(r);
|
|
1138
1136
|
}
|
|
1139
1137
|
async fetchPorts(e, r) {
|
|
1140
1138
|
return {
|
|
1141
1139
|
grpc: {
|
|
1142
|
-
local: await
|
|
1140
|
+
local: await $(),
|
|
1143
1141
|
remote: await this.getFreePortForPlatformaOnServer(e, r)
|
|
1144
1142
|
},
|
|
1145
1143
|
monitoring: {
|
|
1146
|
-
local: await
|
|
1144
|
+
local: await $(),
|
|
1147
1145
|
remote: await this.getFreePortForPlatformaOnServer(e, r)
|
|
1148
1146
|
},
|
|
1149
1147
|
debug: {
|
|
1150
|
-
local: await
|
|
1148
|
+
local: await $(),
|
|
1151
1149
|
remote: await this.getFreePortForPlatformaOnServer(e, r)
|
|
1152
1150
|
},
|
|
1153
1151
|
minioPort: {
|
|
1154
|
-
local: await
|
|
1152
|
+
local: await $(),
|
|
1155
1153
|
remote: await this.getFreePortForPlatformaOnServer(e, r)
|
|
1156
1154
|
},
|
|
1157
1155
|
minioConsolePort: {
|
|
1158
|
-
local: await
|
|
1156
|
+
local: await $(),
|
|
1159
1157
|
remote: await this.getFreePortForPlatformaOnServer(e, r)
|
|
1160
1158
|
}
|
|
1161
1159
|
};
|
|
@@ -1170,7 +1168,7 @@ class Z {
|
|
|
1170
1168
|
});
|
|
1171
1169
|
}
|
|
1172
1170
|
async getFreePortForPlatformaOnServer(e, r) {
|
|
1173
|
-
const t =
|
|
1171
|
+
const t = It(e, r.arch), { stdout: i, stderr: o } = await this.sshClient.exec(`${t}`);
|
|
1174
1172
|
if (o)
|
|
1175
1173
|
throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${o}, stdout: ${i}`);
|
|
1176
1174
|
return +i;
|
|
@@ -1227,7 +1225,7 @@ export {
|
|
|
1227
1225
|
Z as SshPl,
|
|
1228
1226
|
Wt as SshPlPorts,
|
|
1229
1227
|
R as getDefaultPlVersion,
|
|
1230
|
-
|
|
1228
|
+
mr as localPlatformaInit,
|
|
1231
1229
|
qt as newConnectionInfo,
|
|
1232
1230
|
zt as parseConnectionInfo,
|
|
1233
1231
|
Qt as parseGlibcVersion,
|