@milaboratories/pl-deployments 2.4.4 → 2.4.5

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.mjs CHANGED
@@ -4,7 +4,7 @@ var p = (o, t, e) => Q(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { spawn as tt } from "node:child_process";
5
5
  import { sleep as x, fileExists as v, assertNever as j, notEmpty as m, RetryablePromise as et } from "@milaboratories/ts-helpers";
6
6
  import O from "node:fs";
7
- import y, { readFile as rt } from "node:fs/promises";
7
+ import g, { readFile as rt } from "node:fs/promises";
8
8
  import h from "upath";
9
9
  import { request as it } from "undici";
10
10
  import { Readable as nt, Writable as ot } from "node:stream";
@@ -12,13 +12,13 @@ import { text as st } from "node:stream/consumers";
12
12
  import * as at from "tar";
13
13
  import ct from "decompress";
14
14
  import * as lt from "node:os";
15
- import b from "node:os";
15
+ import P from "node:os";
16
16
  import dt, { Client as D } from "ssh2";
17
17
  import G from "node:net";
18
18
  import ht from "node:dns";
19
19
  import { randomBytes as F } from "node:crypto";
20
20
  import { generateSshPlConfigs as ut, getFreePort as $ } from "@milaboratories/pl-config";
21
- import { z as w } from "zod";
21
+ import { z as f } from "zod";
22
22
  function pt(o, t) {
23
23
  return o.info(`Running:
24
24
  cmd: ${JSON.stringify([t.cmd, ...t.args])}
@@ -40,7 +40,7 @@ async function L(o, t) {
40
40
  if (await x(100), r += 100, r > t)
41
41
  throw new Error(`The process did not stopped after ${t} ms.`);
42
42
  }
43
- const wt = ["linux", "macos", "windows"];
43
+ const ft = ["linux", "macos", "windows"];
44
44
  function R(o) {
45
45
  switch (o.toLowerCase()) {
46
46
  case "darwin":
@@ -51,11 +51,11 @@ function R(o) {
51
51
  return "windows";
52
52
  default:
53
53
  throw new Error(
54
- `operating system '${o}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(wt)
54
+ `operating system '${o}' is not currently supported by Platforma ecosystem. The list of OSes supported: ` + JSON.stringify(ft)
55
55
  );
56
56
  }
57
57
  }
58
- const ft = ["amd64", "arm64"];
58
+ const wt = ["amd64", "arm64"];
59
59
  function C(o) {
60
60
  switch (o) {
61
61
  case "aarch64":
@@ -67,7 +67,7 @@ function C(o) {
67
67
  return "amd64";
68
68
  default:
69
69
  throw new Error(
70
- `processor architecture '${o}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(ft)
70
+ `processor architecture '${o}' is not currently supported by Platforma ecosystem. The list of architectures supported: ` + JSON.stringify(wt)
71
71
  );
72
72
  }
73
73
  }
@@ -107,7 +107,7 @@ async function A(o, t, e) {
107
107
  try {
108
108
  if (r.fileExisted = await v(e), r.fileExisted)
109
109
  return o.info(`Platforma Backend archive download skipped: '${e}' already exists`), r;
110
- await y.mkdir(h.dirname(e), { recursive: !0 }), r.dirnameCreated = !0, o.info(`Downloading archive:
110
+ await g.mkdir(h.dirname(e), { recursive: !0 }), r.dirnameCreated = !0, o.info(`Downloading archive:
111
111
  URL: ${t}
112
112
  Save to: ${e}`);
113
113
  const { body: i, statusCode: n } = await it(t);
@@ -115,7 +115,7 @@ async function A(o, t, e) {
115
115
  const s = await st(i);
116
116
  throw r.errorMsg = `failed to download archive: ${n}, response: ${s.slice(0, 1e3)}`, o.error(r.errorMsg), new Error(r.errorMsg);
117
117
  }
118
- return r.tmpPath = e + ".tmp", await nt.toWeb(i).pipeTo(ot.toWeb(O.createWriteStream(r.tmpPath))), r.wroteTmp = !0, r.tmpExisted = await v(r.tmpPath), await y.rename(r.tmpPath, e), r.renamed = !0, r.newExisted = await v(e), r;
118
+ return r.tmpPath = e + ".tmp", await nt.toWeb(i).pipeTo(ot.toWeb(O.createWriteStream(r.tmpPath))), r.wroteTmp = !0, r.tmpExisted = await v(r.tmpPath), await g.rename(r.tmpPath, e), r.renamed = !0, r.newExisted = await v(e), r;
119
119
  } catch (i) {
120
120
  const n = `downloadArchive: ${JSON.stringify(i)}, state: ${JSON.stringify(r)}`;
121
121
  throw o.error(n), new Error(n);
@@ -132,7 +132,7 @@ async function St(o, t, e, r) {
132
132
  o.info(`Platforma Backend binaries unpack skipped: '${r}' exists`);
133
133
  return;
134
134
  }
135
- switch (await v(r) && (o.info(`Removing previous incompletely unpacked folder: '${r}'`), await y.rm(r, { recursive: !0 })), o.info(` creating target dir '${r}'`), await y.mkdir(r, { recursive: !0 }), o.info(
135
+ switch (await v(r) && (o.info(`Removing previous incompletely unpacked folder: '${r}'`), await g.rm(r, { recursive: !0 })), o.info(` creating target dir '${r}'`), await g.mkdir(r, { recursive: !0 }), o.info(
136
136
  `Unpacking Platforma Backend archive:
137
137
  Archive: ${t}
138
138
  Target dir: ${r}`
@@ -150,7 +150,7 @@ async function St(o, t, e, r) {
150
150
  default:
151
151
  j(e);
152
152
  }
153
- await y.writeFile(i, "ok"), o.info(" ... unpack done.");
153
+ await g.writeFile(i, "ok"), o.info(" ... unpack done.");
154
154
  }
155
155
  const Ct = {
156
156
  linux: "tgz",
@@ -166,8 +166,8 @@ function Et() {
166
166
  async function Ft(o, t, e) {
167
167
  switch (e.type) {
168
168
  case "Download":
169
- const r = await vt(o, t, "pl", `pl-${e.version}`, b.arch(), b.platform());
170
- return h.join(r.baseName, "binaries", At[R(b.platform())]);
169
+ const r = await vt(o, t, "pl", `pl-${e.version}`, P.arch(), P.platform());
170
+ return h.join(r.baseName, "binaries", At[R(P.platform())]);
171
171
  case "Local":
172
172
  return e.path;
173
173
  default:
@@ -182,14 +182,14 @@ const At = {
182
182
  function V(o) {
183
183
  return h.join(o, "pl_pid");
184
184
  }
185
- async function Pt(o) {
185
+ async function bt(o) {
186
186
  if (!await v(o))
187
187
  return;
188
- const t = await y.readFile(o);
188
+ const t = await g.readFile(o);
189
189
  return Number(t.toString());
190
190
  }
191
- async function bt(o, t) {
192
- await y.writeFile(o, JSON.stringify(t));
191
+ async function Pt(o, t) {
192
+ await g.writeFile(o, JSON.stringify(t));
193
193
  }
194
194
  function Dt() {
195
195
  return {};
@@ -197,7 +197,7 @@ function Dt() {
197
197
  function xt(o, t, e) {
198
198
  return o[t] = e, e;
199
199
  }
200
- async function U(o, t) {
200
+ async function _(o, t) {
201
201
  const e = Dt();
202
202
  try {
203
203
  return await t((i, n) => xt(e, i, n), e);
@@ -216,7 +216,7 @@ class kt {
216
216
  this.logger = t, this.workingDir = e, this.startOptions = r, this.initialStartHistory = i, this.onClose = n, this.onError = s, this.onCloseAndError = a, this.onCloseAndErrorNoStop = c;
217
217
  }
218
218
  async start() {
219
- await U(this.logger, async (t, e) => {
219
+ await _(this.logger, async (t, e) => {
220
220
  this.wasStopped = !1;
221
221
  const r = pt(this.logger, this.startOptions);
222
222
  r.on("error", (n) => {
@@ -227,7 +227,7 @@ class kt {
227
227
  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);
228
228
  }), t("started", !0);
229
229
  const i = t("pidFile", V(this.workingDir));
230
- t("pid", m(r.pid)), t("pidWritten", await bt(i, m(r.pid))), this.nRuns++, this.instance = r, this.pid = r.pid, this.lastRunHistory = e;
230
+ t("pid", m(r.pid)), t("pidWritten", await Pt(i, m(r.pid))), this.nRuns++, this.instance = r, this.pid = r.pid, this.lastRunHistory = e;
231
231
  });
232
232
  }
233
233
  stop() {
@@ -253,21 +253,21 @@ class kt {
253
253
  };
254
254
  }
255
255
  }
256
- async function Ce(o, t) {
256
+ async function Ee(o, t) {
257
257
  const e = Math.max(lt.cpus().length - 2, 1), r = Nt(t, e);
258
- return await U(o, async (i, n) => {
258
+ return await _(o, async (i, n) => {
259
259
  i("startOptions", { ...r, config: "too wordy" });
260
260
  const s = h.resolve(r.workingDir);
261
261
  r.closeOld && i("closeOld", await Rt(o, s));
262
262
  const a = h.join(s, Ot);
263
- o.info(`writing configuration '${a}'...`), await y.writeFile(a, r.config);
264
- const c = h.join(s, "binaries"), l = await Ft(o, c, r.plBinary), d = i("binaryPath", h.join("binaries", l)), u = Ut(d, a, r, s, process.env);
263
+ o.info(`writing configuration '${a}'...`), await g.writeFile(a, r.config);
264
+ const c = h.join(s, "binaries"), l = await Ft(o, c, r.plBinary), d = i("binaryPath", h.join("binaries", l)), u = _t(d, a, r, s, process.env);
265
265
  i("processOpts", {
266
266
  cmd: u.cmd,
267
267
  args: u.args,
268
268
  cwd: u.opts.cwd
269
269
  });
270
- const f = new kt(
270
+ const w = new kt(
271
271
  o,
272
272
  r.workingDir,
273
273
  u,
@@ -277,12 +277,12 @@ async function Ce(o, t) {
277
277
  r.onCloseAndError,
278
278
  r.onCloseAndErrorNoStop
279
279
  );
280
- return await f.start(), f;
280
+ return await w.start(), w;
281
281
  });
282
282
  }
283
283
  async function Rt(o, t) {
284
- return await U(o, async (e, r) => {
285
- const i = e("pidFilePath", V(t)), n = e("pid", await Pt(i)), s = e("wasAlive", await k(n));
284
+ return await _(o, async (e, r) => {
285
+ const i = e("pidFilePath", V(t)), n = e("pid", await bt(i)), s = e("wasAlive", await k(n));
286
286
  return n !== void 0 && s && (e("stopped", J(n)), e("waitStopped", await L(n, 1e4))), r;
287
287
  });
288
288
  }
@@ -304,7 +304,7 @@ function Nt(o, t) {
304
304
  const r = { ...o };
305
305
  return delete r.spawnOptions, { ...e, ...r };
306
306
  }
307
- function Ut(o, t, e, r, i) {
307
+ function _t(o, t, e, r, i) {
308
308
  var a;
309
309
  const n = {
310
310
  cmd: o,
@@ -321,11 +321,11 @@ function Ut(o, t, e, r, i) {
321
321
  const s = { ...e.spawnOptions };
322
322
  return delete s.env, n.opts = { ...n.opts, ...s }, n;
323
323
  }
324
- const Bt = {
324
+ const Ut = {
325
325
  keepaliveInterval: 6e4,
326
326
  keepaliveCountMax: 10
327
327
  };
328
- class B {
328
+ class U {
329
329
  constructor(t, e) {
330
330
  p(this, "config");
331
331
  p(this, "homeDir");
@@ -339,9 +339,9 @@ class B {
339
339
  */
340
340
  static async init(t, e) {
341
341
  const r = {
342
- ...Bt,
342
+ ...Ut,
343
343
  ...e
344
- }, i = new B(t, new D());
344
+ }, i = new U(t, new D());
345
345
  return await i.connect(r), i;
346
346
  }
347
347
  getForwardedServers() {
@@ -361,7 +361,7 @@ class B {
361
361
  * @returns A promise that resolves when the connection is established or rejects on error.
362
362
  */
363
363
  async connect(t) {
364
- return this.config = t, await It(this.client, t);
364
+ return this.config = t, await Bt(this.client, t);
365
365
  }
366
366
  /**
367
367
  * Executes a command on the SSH server.
@@ -446,20 +446,20 @@ class B {
446
446
  let d;
447
447
  try {
448
448
  d = await i.ensure();
449
- } catch (f) {
450
- this.logger.info(`${l}.persistentClient.catch: ${f}`), c.end();
449
+ } catch (w) {
450
+ this.logger.info(`${l}.persistentClient.catch: ${w}`), c.end();
451
451
  return;
452
452
  }
453
453
  d.setNoDelay(!0), c.setNoDelay(!0);
454
454
  let u;
455
455
  try {
456
- u = await _t(this.logger, d, "127.0.0.1", 0, "127.0.0.1", t.remotePort);
457
- } catch (f) {
458
- this.logger.error(`${l}.forwardOut.err: ${f}`), c.end();
456
+ u = await It(this.logger, d, "127.0.0.1", 0, "127.0.0.1", t.remotePort);
457
+ } catch (w) {
458
+ this.logger.error(`${l}.forwardOut.err: ${w}`), c.end();
459
459
  return;
460
460
  }
461
- c.pipe(u), u.pipe(c), c.resume(), u.on("error", (f) => {
462
- this.logger.error(`${l}.stream.error: ${f}`), c.end(), u.end();
461
+ c.pipe(u), u.pipe(c), c.resume(), u.on("error", (w) => {
462
+ this.logger.error(`${l}.stream.error: ${w}`), c.end(), u.end();
463
463
  }), u.on("close", () => {
464
464
  c.end(), u.end();
465
465
  }), c.on("close", () => {
@@ -762,7 +762,7 @@ class B {
762
762
  this.closeForwardedPorts(), this.client.end();
763
763
  }
764
764
  }
765
- async function It(o, t, e, r) {
765
+ async function Bt(o, t, e, r) {
766
766
  return new Promise((i, n) => {
767
767
  o.on("ready", () => {
768
768
  i(o);
@@ -772,55 +772,58 @@ async function It(o, t, e, r) {
772
772
  }), o.connect(t), o.setNoDelay(!0);
773
773
  });
774
774
  }
775
- async function _t(o, t, e, r, i, n) {
775
+ async function It(o, t, e, r, i, n) {
776
776
  return new Promise((s, a) => {
777
777
  t.forwardOut(e, r, i, n, (c, l) => c ? (o.error(`forwardOut.error: ${c}`), a(c)) : s(l));
778
778
  });
779
779
  }
780
780
  const Tt = "minio-2024-12-18T13-15-44Z", Mt = "supervisord-0.7.3", Ht = "supervisord_0.7.3_Linux_64-bit";
781
- function g(o) {
781
+ function y(o) {
782
782
  return h.join(o, ".platforma_ssh");
783
783
  }
784
- function P(o) {
785
- return h.join(g(o), "binaries");
784
+ function b(o) {
785
+ return h.join(y(o), "binaries");
786
786
  }
787
787
  function jt(o, t) {
788
- return h.join(P(o), `pl-${N()}-${C(t)}`);
788
+ return h.join(b(o), `pl-${N()}-${C(t)}`);
789
789
  }
790
- function W(o, t) {
790
+ function q(o, t) {
791
791
  return h.join(jt(o, t), "binaries");
792
792
  }
793
- function _(o, t) {
794
- return h.join(W(o, t), "platforma");
793
+ function I(o, t) {
794
+ return h.join(q(o, t), "platforma");
795
795
  }
796
796
  function Gt(o, t) {
797
- return h.join(W(o, t), "free-port");
797
+ return h.join(q(o, t), "free-port");
798
798
  }
799
- function q(o, t) {
800
- return h.join(P(o), `minio-2024-12-18T13-15-44Z-${C(t)}`);
799
+ function W(o, t) {
800
+ return h.join(b(o), `minio-2024-12-18T13-15-44Z-${C(t)}`);
801
801
  }
802
802
  function Jt(o, t) {
803
- return h.join(q(o, t), "minio");
803
+ return h.join(W(o, t), "minio");
804
804
  }
805
805
  function Lt(o, t) {
806
- return h.join(P(o), `supervisord-0.7.3-${C(t)}`, Ht);
806
+ return h.join(b(o), `supervisord-0.7.3-${C(t)}`, Ht);
807
807
  }
808
808
  function K(o, t) {
809
809
  return h.join(Lt(o, t), "supervisord");
810
810
  }
811
811
  function Z(o) {
812
- return h.join(g(o), "supervisor.conf");
812
+ return h.join(y(o), "supervisor.conf");
813
813
  }
814
814
  function T(o) {
815
- return h.join(g(o), "connection.txt");
815
+ return h.join(y(o), "connection.txt");
816
+ }
817
+ function zt(o) {
818
+ return h.join(y(o), "platforma_cli_logs.log");
816
819
  }
817
- async function zt(o, t, e) {
818
- const r = await I(o, t, e, "--daemon");
820
+ async function Vt(o, t, e) {
821
+ const r = await B(o, t, e, "--daemon");
819
822
  if (r.stderr)
820
823
  throw new Error(`Can not run ssh Platforma ${r.stderr}`);
821
824
  }
822
- async function Vt(o, t, e) {
823
- const r = await I(o, t, e, "ctl shutdown");
825
+ async function qt(o, t, e) {
826
+ const r = await B(o, t, e, "ctl shutdown");
824
827
  if (r.stderr)
825
828
  throw new Error(`Can not stop ssh Platforma ${r.stderr}`);
826
829
  }
@@ -830,10 +833,10 @@ function E(o, t) {
830
833
  function Wt(o) {
831
834
  return o.execError === void 0;
832
835
  }
833
- async function qt(o, t, e, r) {
836
+ async function Kt(o, t, e, r) {
834
837
  let i;
835
838
  try {
836
- i = await I(t, e, r, "ctl status");
839
+ i = await B(t, e, r, "ctl status");
837
840
  } catch (c) {
838
841
  return { execError: String(c) };
839
842
  }
@@ -846,7 +849,7 @@ async function qt(o, t, e, r) {
846
849
  };
847
850
  return a.minio || o.warn("Minio is not running on the server"), a.platforma || o.warn("Platforma is not running on the server"), a;
848
851
  }
849
- function Kt(o, t, e, r) {
852
+ function Zt(o, t, e, r) {
850
853
  const i = F(16).toString("hex"), n = o;
851
854
  return `
852
855
  [supervisord]
@@ -869,9 +872,13 @@ autostart=true
869
872
  command=${r} --config ${e}
870
873
  directory=${t}
871
874
  autorestart=true
875
+ stdout_logfile=${t}/platforma_cli_logs.log
876
+ stdout_logfile_maxbytes=10000
877
+ stdout_logfile_backups=10
878
+ redirect_stderr=true
872
879
  `;
873
880
  }
874
- function Zt(o, t, e, r, i, n, s) {
881
+ function Xt(o, t, e, r, i, n, s) {
875
882
  const a = Object.entries(t).map(([d, u]) => `${d}="${u}"`).join(","), c = F(16).toString("hex"), l = e;
876
883
  return `
877
884
  [supervisord]
@@ -904,7 +911,7 @@ directory=${r}
904
911
  autorestart=true
905
912
  `;
906
913
  }
907
- async function I(o, t, e, r) {
914
+ async function B(o, t, e, r) {
908
915
  const i = K(t, e), n = Z(t), s = `${i} --configuration ${n} ${r}`;
909
916
  return await o.exec(s);
910
917
  }
@@ -915,10 +922,10 @@ function M(o, t) {
915
922
  return n === t && s === "Running";
916
923
  });
917
924
  }
918
- const S = w.object({
919
- local: w.number(),
920
- remote: w.number()
921
- }), Xt = w.object({
925
+ const S = f.object({
926
+ local: f.number(),
927
+ remote: f.number()
928
+ }), Yt = f.object({
922
929
  grpc: S,
923
930
  http: S.optional(),
924
931
  monitoring: S,
@@ -927,19 +934,19 @@ const S = w.object({
927
934
  minioPort: S,
928
935
  /** @deprecated */
929
936
  minioConsolePort: S
930
- }), Yt = w.object({
931
- plUser: w.string(),
932
- plPassword: w.string(),
933
- ports: Xt,
937
+ }), Qt = f.object({
938
+ plUser: f.string(),
939
+ plPassword: f.string(),
940
+ ports: Yt,
934
941
  // It's false by default because it was added later,
935
942
  // and in some deployments there won't be useGlobalAccess flag in the file.
936
- useGlobalAccess: w.boolean().default(!1),
943
+ useGlobalAccess: f.boolean().default(!1),
937
944
  // We added the field afterwards, the pl backend was this version.
938
- plVersion: w.string().default("1.18.3"),
945
+ plVersion: f.string().default("1.18.3"),
939
946
  // It's true by default because it was added later and previous installation use minio.
940
- minioIsUsed: w.boolean().default(!0)
947
+ minioIsUsed: f.boolean().default(!0)
941
948
  });
942
- function Qt(o, t, e, r, i, n) {
949
+ function te(o, t, e, r, i, n) {
943
950
  return {
944
951
  plUser: o,
945
952
  plPassword: t,
@@ -949,10 +956,10 @@ function Qt(o, t, e, r, i, n) {
949
956
  minioIsUsed: n
950
957
  };
951
958
  }
952
- function te(o) {
953
- return Yt.parse(JSON.parse(o));
954
- }
955
959
  function ee(o) {
960
+ return Qt.parse(JSON.parse(o));
961
+ }
962
+ function re(o) {
956
963
  return JSON.stringify(o, void 0, 2);
957
964
  }
958
965
  const H = 2.28;
@@ -969,7 +976,7 @@ class X {
969
976
  }
970
977
  static async init(t, e) {
971
978
  try {
972
- const r = await B.init(t, e);
979
+ const r = await U.init(t, e);
973
980
  return new X(t, r, m(e.username));
974
981
  } catch (r) {
975
982
  throw t.error(`Connection error in SshClient.init: ${r}`), r;
@@ -981,7 +988,7 @@ class X {
981
988
  /** Provides an info if the platforma and minio are running along with the debug info. */
982
989
  async isAlive() {
983
990
  const t = await this.getArch(), e = await this.getUserHomeDirectory();
984
- return await qt(this.logger, this.sshClient, e, t.arch);
991
+ return await Kt(this.logger, this.sshClient, e, t.arch);
985
992
  }
986
993
  /** Starts all the services on the server.
987
994
  * Idempotent semantic: we could call it several times. */
@@ -989,9 +996,14 @@ class X {
989
996
  const e = await this.getArch(), r = await this.getUserHomeDirectory();
990
997
  try {
991
998
  if (!E(await this.isAlive(), t))
992
- return await zt(this.sshClient, r, e.arch), await this.checkIsAliveWithInterval(t);
999
+ return await Vt(this.sshClient, r, e.arch), await this.checkIsAliveWithInterval(t);
993
1000
  } catch (i) {
994
- const n = `SshPl.start: ${i}`;
1001
+ let n = `SshPl.start: ${i}`, s = "";
1002
+ try {
1003
+ s = await this.sshClient.readFile(zt(r)), n += `, platforma cli logs: ${s}`;
1004
+ } catch (a) {
1005
+ n += `, Can not read platforma cli logs: ${a}`;
1006
+ }
995
1007
  throw this.logger.error(n), new Error(n);
996
1008
  }
997
1009
  }
@@ -1002,7 +1014,7 @@ class X {
1002
1014
  try {
1003
1015
  const r = await this.isAlive();
1004
1016
  if (Wt(r)) {
1005
- await Vt(this.sshClient, e, t.arch);
1017
+ await qt(this.sshClient, e, t.arch);
1006
1018
  const i = r.minio === !0;
1007
1019
  return await this.checkIsAliveWithInterval(i, 1e3, 15, !1);
1008
1020
  }
@@ -1018,14 +1030,14 @@ class X {
1018
1030
  /** Stops platforma and deletes its state. */
1019
1031
  async stopAndClean() {
1020
1032
  const t = await this.getUserHomeDirectory();
1021
- this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${g(t)} on the server`), await this.sshClient.deleteFolder(g(t));
1033
+ this.logger.info("pl.reset: Stop Platforma on the server"), await this.stop(), this.logger.info(`pl.reset: Deleting Platforma workDir ${y(t)} on the server`), await this.sshClient.deleteFolder(y(t));
1022
1034
  }
1023
1035
  /** Downloads binaries and untar them on the server,
1024
1036
  * generates all the configs, creates necessary dirs,
1025
1037
  * and finally starts all the services. */
1026
1038
  async platformaInit(t) {
1027
1039
  const e = { localWorkdir: t.localWorkdir, step: "init" }, { onProgress: r } = t, i = {
1028
- ...re,
1040
+ ...ie,
1029
1041
  ...t
1030
1042
  };
1031
1043
  e.plBinaryOps = i.plBinary;
@@ -1049,7 +1061,7 @@ class X {
1049
1061
  async doStepSaveNewConnectionInfo(t, e, r) {
1050
1062
  t.step = "saveNewConnectionInfo";
1051
1063
  const i = t.generatedConfig;
1052
- await (e == null ? void 0 : e("Saving connection information...")), t.connectionInfo = Qt(
1064
+ await (e == null ? void 0 : e("Saving connection information...")), t.connectionInfo = te(
1053
1065
  i.plUser,
1054
1066
  i.plPassword,
1055
1067
  t.ports,
@@ -1058,14 +1070,14 @@ class X {
1058
1070
  t.shouldUseMinio ?? !1
1059
1071
  ), await this.sshClient.writeFileOnTheServer(
1060
1072
  T(t.remoteHome),
1061
- ee(t.connectionInfo)
1073
+ re(t.connectionInfo)
1062
1074
  ), await (e == null ? void 0 : e("Connection information saved."));
1063
1075
  }
1064
1076
  async doStepConfigureSupervisord(t, e) {
1065
1077
  await (e == null ? void 0 : e("Writing supervisord configuration...")), t.step = "configureSupervisord";
1066
1078
  const r = t.generatedConfig;
1067
1079
  let i;
1068
- if (t.shouldUseMinio ? i = Zt(
1080
+ if (t.shouldUseMinio ? i = Xt(
1069
1081
  r.minioConfig.storageDir,
1070
1082
  r.minioConfig.envs,
1071
1083
  await this.getFreePortForPlatformaOnServer(t.remoteHome, t.arch),
@@ -1073,13 +1085,13 @@ class X {
1073
1085
  r.plConfig.configPath,
1074
1086
  t.binPaths.minioRelPath,
1075
1087
  t.binPaths.downloadedPl
1076
- ) : i = Kt(
1088
+ ) : i = Zt(
1077
1089
  await this.getFreePortForPlatformaOnServer(t.remoteHome, t.arch),
1078
1090
  r.workingDir,
1079
1091
  r.plConfig.configPath,
1080
1092
  t.binPaths.downloadedPl
1081
1093
  ), !await this.sshClient.writeFileOnTheServer(Z(t.remoteHome), i))
1082
- throw new Error(`Can not write supervisord config on the server ${g(t.remoteHome)}`);
1094
+ throw new Error(`Can not write supervisord config on the server ${y(t.remoteHome)}`);
1083
1095
  await (e == null ? void 0 : e("Supervisord configuration written."));
1084
1096
  }
1085
1097
  async doStepCreateFoldersAndSaveFiles(t, e) {
@@ -1096,7 +1108,7 @@ class X {
1096
1108
  t.step = "generateNewConfig", await (e == null ? void 0 : e("Generating new config..."));
1097
1109
  const i = await ut({
1098
1110
  logger: this.logger,
1099
- workingDir: g(t.remoteHome),
1111
+ workingDir: y(t.remoteHome),
1100
1112
  portsMode: {
1101
1113
  type: "customWithMinio",
1102
1114
  ports: {
@@ -1125,7 +1137,7 @@ class X {
1125
1137
  }
1126
1138
  async doStepDownloadBinaries(t, e, r) {
1127
1139
  t.step = "downloadBinaries", await (e == null ? void 0 : e("Downloading and uploading required binaries..."));
1128
- const i = await ie(this.logger, this.sshClient);
1140
+ const i = await ne(this.logger, this.sshClient);
1129
1141
  if (i < H)
1130
1142
  throw new Error(`glibc version ${i} is too old. Version ${H} or higher is required for Platforma.`);
1131
1143
  const n = await this.downloadBinariesAndUploadToTheServer(
@@ -1185,7 +1197,7 @@ class X {
1185
1197
  return {
1186
1198
  history: s,
1187
1199
  minioRelPath: n ? l : void 0,
1188
- downloadedPl: _(r, i.arch)
1200
+ downloadedPl: I(r, i.arch)
1189
1201
  };
1190
1202
  } catch (a) {
1191
1203
  const c = `SshPl.downloadBinariesAndUploadToServer: ${a}, state: ${JSON.stringify(s)}`;
@@ -1200,7 +1212,7 @@ class X {
1200
1212
  * (it's not installed for Rocky Linux for example). */
1201
1213
  async downloadAndUntar(t, e, r, i, n) {
1202
1214
  const s = {};
1203
- s.binBasePath = P(e), await this.sshClient.ensureRemoteDirCreated(s.binBasePath), s.binBasePathCreated = !0;
1215
+ s.binBasePath = b(e), await this.sshClient.ensureRemoteDirCreated(s.binBasePath), s.binBasePathCreated = !0;
1204
1216
  let a = null;
1205
1217
  const c = 5;
1206
1218
  for (let d = 1; d <= c; d++)
@@ -1232,7 +1244,7 @@ class X {
1232
1244
  return s.untarDone = !0, s;
1233
1245
  }
1234
1246
  async needDownload(t, e) {
1235
- const r = K(t, e.arch), i = q(t, e.arch), n = _(t, e.arch);
1247
+ const r = K(t, e.arch), i = W(t, e.arch), n = I(t, e.arch);
1236
1248
  return !await this.sshClient.checkFileExists(n) || !await this.sshClient.checkFileExists(i) || !await this.sshClient.checkFileExists(r);
1237
1249
  }
1238
1250
  async checkIsAliveWithInterval(t, e = 1e3, r = 15, i = !0) {
@@ -1246,7 +1258,7 @@ class X {
1246
1258
  }
1247
1259
  async readExistedConfig(t) {
1248
1260
  const e = await this.sshClient.readFile(T(t));
1249
- return te(e);
1261
+ return ee(e);
1250
1262
  }
1251
1263
  async fetchPorts(t, e) {
1252
1264
  return {
@@ -1311,44 +1323,44 @@ class X {
1311
1323
  return t.trim();
1312
1324
  }
1313
1325
  }
1314
- const re = {
1326
+ const ie = {
1315
1327
  useGlobalAccess: !1,
1316
1328
  plBinary: {
1317
1329
  type: "Download",
1318
1330
  version: N()
1319
1331
  }
1320
1332
  };
1321
- async function ie(o, t) {
1333
+ async function ne(o, t) {
1322
1334
  try {
1323
1335
  const { stdout: e, stderr: r } = await t.exec("ldd --version | head -n 1");
1324
1336
  if (r)
1325
1337
  throw new Error(`Failed to check glibc version: ${r}`);
1326
- return ne(e);
1338
+ return oe(e);
1327
1339
  } catch (e) {
1328
1340
  throw o.error(`glibc version check failed: ${e}`), e;
1329
1341
  }
1330
1342
  }
1331
- function ne(o) {
1343
+ function oe(o) {
1332
1344
  const t = o.match(/\d+\.\d+/);
1333
1345
  if (!t)
1334
1346
  throw new Error(`Could not parse glibc version from: ${o}`);
1335
1347
  return parseFloat(t[0]);
1336
1348
  }
1337
1349
  export {
1338
- Yt as ConnectionInfo,
1350
+ Qt as ConnectionInfo,
1339
1351
  Ot as LocalConfigYaml,
1340
1352
  kt as LocalPl,
1341
1353
  S as PortPair,
1342
- B as SshClient,
1354
+ U as SshClient,
1343
1355
  X as SshPl,
1344
- Xt as SshPlPorts,
1356
+ Yt as SshPlPorts,
1345
1357
  N as getDefaultPlVersion,
1346
- Ce as localPlatformaInit,
1358
+ Ee as localPlatformaInit,
1347
1359
  Nt as mergeDefaultOps,
1348
- Qt as newConnectionInfo,
1349
- te as parseConnectionInfo,
1350
- ne as parseGlibcVersion,
1351
- Ut as plProcessOps,
1352
- ee as stringifyConnectionInfo
1360
+ te as newConnectionInfo,
1361
+ ee as parseConnectionInfo,
1362
+ oe as parseGlibcVersion,
1363
+ _t as plProcessOps,
1364
+ re as stringifyConnectionInfo
1353
1365
  };
1354
1366
  //# sourceMappingURL=index.mjs.map