@milaboratories/pl-deployments 1.1.1 → 1.1.2
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 +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -44
- package/dist/index.mjs.map +1 -1
- package/dist/ssh/__tests__/common-utils.d.ts.map +1 -1
- package/dist/ssh/ssh.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ssh/__tests__/common-utils.ts +2 -1
- package/src/ssh/__tests__/ssh-docker.test.ts +52 -1
- package/src/ssh/ssh.ts +13 -4
package/dist/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ async function ht(s, r, t, e, o) {
|
|
|
78
78
|
return await H(s, n, a), await pt(s, a, c, l), i;
|
|
79
79
|
}
|
|
80
80
|
function ut(s, r, t, e, o) {
|
|
81
|
-
const i = `${r}-${e}`, n =
|
|
81
|
+
const i = `${r}-${e}`, n = I[o], a = `${i}.${n}`, c = `https://cdn.platforma.bio/software/${s}/${o}/${a}`, l = h.join(t, a), u = h.join(t, i);
|
|
82
82
|
return {
|
|
83
83
|
archiveUrl: c,
|
|
84
84
|
archivePath: l,
|
|
@@ -88,7 +88,7 @@ function ut(s, r, t, e, o) {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
function dt(s, r, t, e) {
|
|
91
|
-
const o = `pl-${s}-${t}`, i =
|
|
91
|
+
const o = `pl-${s}-${t}`, i = I[e], n = `${o}.${i}`, a = `https://cdn.platforma.bio/software/pl/${e}/${n}`, c = h.join(r, n), l = h.join(r, o), u = h.join(o, "binaries", ft[e]);
|
|
92
92
|
return {
|
|
93
93
|
archiveUrl: a,
|
|
94
94
|
archivePath: c,
|
|
@@ -149,7 +149,7 @@ async function pt(s, r, t, e) {
|
|
|
149
149
|
}
|
|
150
150
|
await w.writeFile(o, "ok"), s.info(" ... unpack done.");
|
|
151
151
|
}
|
|
152
|
-
const
|
|
152
|
+
const I = {
|
|
153
153
|
linux: "tgz",
|
|
154
154
|
macos: "tgz",
|
|
155
155
|
windows: "zip"
|
|
@@ -174,7 +174,7 @@ async function yt(s, r, t) {
|
|
|
174
174
|
N(t);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
function
|
|
177
|
+
function j(s) {
|
|
178
178
|
return h.join(s, "pl_pid");
|
|
179
179
|
}
|
|
180
180
|
async function gt(s) {
|
|
@@ -221,7 +221,7 @@ class Et {
|
|
|
221
221
|
}), e.on("close", () => {
|
|
222
222
|
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);
|
|
223
223
|
}), r("started", !0);
|
|
224
|
-
const o = r("pidFile",
|
|
224
|
+
const o = r("pidFile", j(this.workingDir));
|
|
225
225
|
r("pid", p(e.pid)), r("pidWritten", await $t(o, p(e.pid))), this.nRuns++, this.instance = e, this.pid = e.pid, this.lastRunHistory = t;
|
|
226
226
|
});
|
|
227
227
|
}
|
|
@@ -248,7 +248,7 @@ class Et {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
-
async function
|
|
251
|
+
async function Xt(s, r) {
|
|
252
252
|
const t = {
|
|
253
253
|
plBinary: mt(),
|
|
254
254
|
spawnOptions: {},
|
|
@@ -293,11 +293,15 @@ async function Qt(s, r) {
|
|
|
293
293
|
}
|
|
294
294
|
async function Ct(s, r) {
|
|
295
295
|
return await A(s, async (t, e) => {
|
|
296
|
-
const o = t("pidFilePath",
|
|
296
|
+
const o = t("pidFilePath", j(r)), i = t("pid", await gt(o)), n = t("wasAlive", await C(i));
|
|
297
297
|
return i !== void 0 && n && (t("stopped", U(i)), t("waitStopped", await B(i, 1e4))), e;
|
|
298
298
|
});
|
|
299
299
|
}
|
|
300
|
-
|
|
300
|
+
const bt = {
|
|
301
|
+
keepaliveInterval: 6e4,
|
|
302
|
+
keepaliveCountMax: 10
|
|
303
|
+
};
|
|
304
|
+
class D {
|
|
301
305
|
constructor(r, t) {
|
|
302
306
|
d(this, "config");
|
|
303
307
|
d(this, "homeDir");
|
|
@@ -309,8 +313,11 @@ class F {
|
|
|
309
313
|
* @returns A new instance of SshClient with an active connection.
|
|
310
314
|
*/
|
|
311
315
|
static async init(r, t) {
|
|
312
|
-
const e =
|
|
313
|
-
|
|
316
|
+
const e = {
|
|
317
|
+
...bt,
|
|
318
|
+
...t
|
|
319
|
+
}, o = new D(r, new v());
|
|
320
|
+
return await o.connect(e), o;
|
|
314
321
|
}
|
|
315
322
|
/**
|
|
316
323
|
* Connects to the SSH server using the specified configuration.
|
|
@@ -423,9 +430,9 @@ class F {
|
|
|
423
430
|
this.logger.info(`Server closed ${JSON.stringify(r)}`), i && (this.logger.info("End SSH connection"), i.end());
|
|
424
431
|
});
|
|
425
432
|
}), i.on("error", (a) => {
|
|
426
|
-
|
|
433
|
+
this.logger.error(`[SSH] SSH connection error, ports: ${JSON.stringify(r)}, err: ${a.message}`), n == null || n.close(), o(`ssh.forwardPort: conn.err: ${a}`);
|
|
427
434
|
}), i.on("close", () => {
|
|
428
|
-
this.logger.info(`[SSH] Connection closed, ports: ${r}`);
|
|
435
|
+
this.logger.info(`[SSH] Connection closed, ports: ${JSON.stringify(r)}`);
|
|
429
436
|
}), i.connect(t);
|
|
430
437
|
});
|
|
431
438
|
}
|
|
@@ -660,36 +667,36 @@ class F {
|
|
|
660
667
|
this.client.end();
|
|
661
668
|
}
|
|
662
669
|
}
|
|
663
|
-
const
|
|
670
|
+
const At = "minio-2024-12-18T13-15-44Z", Dt = "supervisord-0.7.3", Ft = "supervisord_0.7.3_Linux_64-bit";
|
|
664
671
|
function $(s) {
|
|
665
672
|
return h.join(s, "platforma_ssh");
|
|
666
673
|
}
|
|
667
674
|
function P(s) {
|
|
668
675
|
return h.join(s, "platforma_ssh", "binaries");
|
|
669
676
|
}
|
|
670
|
-
function
|
|
677
|
+
function xt(s, r) {
|
|
671
678
|
return h.join(P(s), `pl-${b()}-${g(r)}`);
|
|
672
679
|
}
|
|
673
|
-
function
|
|
674
|
-
return h.join(
|
|
680
|
+
function J(s, r) {
|
|
681
|
+
return h.join(xt(s, r), "binaries");
|
|
675
682
|
}
|
|
676
683
|
function O(s, r) {
|
|
677
|
-
return h.join(
|
|
684
|
+
return h.join(J(s, r), "platforma");
|
|
678
685
|
}
|
|
679
|
-
function
|
|
680
|
-
return h.join(
|
|
686
|
+
function Ot(s, r) {
|
|
687
|
+
return h.join(J(s, r), "free-port");
|
|
681
688
|
}
|
|
682
|
-
function
|
|
689
|
+
function M(s, r) {
|
|
683
690
|
return h.join(P(s), `minio-2024-12-18T13-15-44Z-${g(r)}`);
|
|
684
691
|
}
|
|
685
|
-
function Ot(s, r) {
|
|
686
|
-
return h.join(J(s, r), "minio");
|
|
687
|
-
}
|
|
688
692
|
function kt(s, r) {
|
|
693
|
+
return h.join(M(s, r), "minio");
|
|
694
|
+
}
|
|
695
|
+
function Rt(s, r) {
|
|
689
696
|
return h.join(P(s), `supervisord-0.7.3-${g(r)}`, Ft);
|
|
690
697
|
}
|
|
691
698
|
function L(s, r) {
|
|
692
|
-
return h.join(
|
|
699
|
+
return h.join(Rt(s, r), "supervisord");
|
|
693
700
|
}
|
|
694
701
|
function z(s) {
|
|
695
702
|
return h.join($(s), "supervisor.conf");
|
|
@@ -697,18 +704,18 @@ function z(s) {
|
|
|
697
704
|
function k(s) {
|
|
698
705
|
return h.join($(s), "connection.txt");
|
|
699
706
|
}
|
|
700
|
-
async function
|
|
701
|
-
const e = await
|
|
707
|
+
async function Nt(s, r, t) {
|
|
708
|
+
const e = await F(s, r, t, "--daemon");
|
|
702
709
|
if (e.stderr)
|
|
703
710
|
throw new Error(`Can not run ssh Platforma ${e.stderr}`);
|
|
704
711
|
}
|
|
705
|
-
async function
|
|
706
|
-
const e = await
|
|
712
|
+
async function Tt(s, r, t) {
|
|
713
|
+
const e = await F(s, r, t, "ctl shutdown");
|
|
707
714
|
if (e.stderr)
|
|
708
715
|
throw new Error(`Can not stop ssh Platforma ${e.stderr}`);
|
|
709
716
|
}
|
|
710
|
-
async function
|
|
711
|
-
const o = await
|
|
717
|
+
async function Ut(s, r, t, e) {
|
|
718
|
+
const o = await F(r, t, e, "ctl status");
|
|
712
719
|
if (o.stderr)
|
|
713
720
|
return s.info(`supervisord ctl status: stderr occurred: ${o.stderr}, stdout: ${o.stdout}`), !1;
|
|
714
721
|
const i = {
|
|
@@ -717,7 +724,7 @@ async function Tt(s, r, t, e) {
|
|
|
717
724
|
};
|
|
718
725
|
return i.platforma && i.minio ? !0 : (i.minio || s.warn("Minio is not running on the server"), i.platforma || s.warn("Platforma is not running on the server"), !1);
|
|
719
726
|
}
|
|
720
|
-
function
|
|
727
|
+
function Bt(s, r, t, e, o, i, n) {
|
|
721
728
|
const a = Object.entries(r).map(([u, m]) => `${u}="${m}"`).join(","), c = nt(16).toString("hex"), l = t;
|
|
722
729
|
return `
|
|
723
730
|
[supervisord]
|
|
@@ -750,7 +757,7 @@ directory=${e}
|
|
|
750
757
|
autorestart=true
|
|
751
758
|
`;
|
|
752
759
|
}
|
|
753
|
-
async function
|
|
760
|
+
async function F(s, r, t, e) {
|
|
754
761
|
const o = L(r, t), i = z(r), n = `${o} --configuration ${i} ${e}`;
|
|
755
762
|
return await s.exec(n);
|
|
756
763
|
}
|
|
@@ -774,7 +781,7 @@ class W {
|
|
|
774
781
|
}
|
|
775
782
|
static async init(r, t) {
|
|
776
783
|
try {
|
|
777
|
-
const e = await
|
|
784
|
+
const e = await D.init(r, t);
|
|
778
785
|
return new W(r, e, p(t.username));
|
|
779
786
|
} catch (e) {
|
|
780
787
|
throw r.error(`Connection error in SshClient.init: ${e}`), e;
|
|
@@ -783,7 +790,7 @@ class W {
|
|
|
783
790
|
async isAlive() {
|
|
784
791
|
const r = await this.getArch(), t = await this.getUserHomeDirectory();
|
|
785
792
|
try {
|
|
786
|
-
return await
|
|
793
|
+
return await Ut(this.logger, this.sshClient, t, r.arch);
|
|
787
794
|
} catch {
|
|
788
795
|
return !1;
|
|
789
796
|
}
|
|
@@ -791,7 +798,7 @@ class W {
|
|
|
791
798
|
async start() {
|
|
792
799
|
const r = await this.getArch(), t = await this.getUserHomeDirectory();
|
|
793
800
|
try {
|
|
794
|
-
return await
|
|
801
|
+
return await Nt(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval();
|
|
795
802
|
} catch (e) {
|
|
796
803
|
const o = `ssh.start: error occurred ${e}`;
|
|
797
804
|
throw this.logger.error(o), new Error(o);
|
|
@@ -800,7 +807,7 @@ class W {
|
|
|
800
807
|
async stop() {
|
|
801
808
|
const r = await this.getArch(), t = await this.getUserHomeDirectory();
|
|
802
809
|
try {
|
|
803
|
-
return await
|
|
810
|
+
return await Tt(this.sshClient, t, r.arch), await this.checkIsAliveWithInterval(void 0, void 0, !1);
|
|
804
811
|
} catch (e) {
|
|
805
812
|
const o = `ssh.stop: error occurred ${e}`;
|
|
806
813
|
throw this.logger.error(o), new Error(o);
|
|
@@ -845,7 +852,7 @@ class W {
|
|
|
845
852
|
await this.sshClient.writeFileOnTheServer(a, c), this.logger.info(`Created file ${a}`);
|
|
846
853
|
for (const a of o.dirsToCreate)
|
|
847
854
|
await this.sshClient.createRemoteDirectory(a), this.logger.info(`Created directory ${a}`);
|
|
848
|
-
const i =
|
|
855
|
+
const i = Bt(
|
|
849
856
|
o.minioConfig.storageDir,
|
|
850
857
|
o.minioConfig.envs,
|
|
851
858
|
await this.getFreePortForPlatformaOnServer(t.remoteHome, t.arch),
|
|
@@ -889,15 +896,15 @@ class W {
|
|
|
889
896
|
t,
|
|
890
897
|
e,
|
|
891
898
|
"supervisord",
|
|
892
|
-
|
|
899
|
+
Dt
|
|
893
900
|
);
|
|
894
901
|
o.push(n);
|
|
895
|
-
const a =
|
|
902
|
+
const a = kt(t, e.arch), c = await this.downloadAndUntar(
|
|
896
903
|
r,
|
|
897
904
|
t,
|
|
898
905
|
e,
|
|
899
906
|
"minio",
|
|
900
|
-
|
|
907
|
+
At
|
|
901
908
|
);
|
|
902
909
|
return o.push(c), await this.sshClient.chmod(a, 488), {
|
|
903
910
|
history: o,
|
|
@@ -942,7 +949,7 @@ class W {
|
|
|
942
949
|
return n.plUntarDone = !0, n;
|
|
943
950
|
}
|
|
944
951
|
async needDownload(r, t) {
|
|
945
|
-
const e = L(r, t.arch), o =
|
|
952
|
+
const e = L(r, t.arch), o = M(r, t.arch), i = O(r, t.arch);
|
|
946
953
|
return !await this.sshClient.checkFileExists(i) || !await this.sshClient.checkFileExists(o) || !await this.sshClient.checkFileExists(e);
|
|
947
954
|
}
|
|
948
955
|
async checkIsAliveWithInterval(r = 1e3, t = 15, e = !0) {
|
|
@@ -992,7 +999,7 @@ class W {
|
|
|
992
999
|
});
|
|
993
1000
|
}
|
|
994
1001
|
async getFreePortForPlatformaOnServer(r, t) {
|
|
995
|
-
const e =
|
|
1002
|
+
const e = Ot(r, t.arch), { stdout: o, stderr: i } = await this.sshClient.exec(`${e}`);
|
|
996
1003
|
if (i)
|
|
997
1004
|
throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${i}, stdout: ${o}`);
|
|
998
1005
|
return +o;
|
|
@@ -1020,9 +1027,9 @@ class W {
|
|
|
1020
1027
|
export {
|
|
1021
1028
|
St as LocalConfigYaml,
|
|
1022
1029
|
Et as LocalPl,
|
|
1023
|
-
|
|
1030
|
+
D as SshClient,
|
|
1024
1031
|
W as SshPl,
|
|
1025
1032
|
b as getDefaultPlVersion,
|
|
1026
|
-
|
|
1033
|
+
Xt as localPlatformaInit
|
|
1027
1034
|
};
|
|
1028
1035
|
//# sourceMappingURL=index.mjs.map
|