@milaboratories/pl-deployments 2.8.1 → 2.9.0
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/pl_binary.cjs +10 -2
- package/dist/common/pl_binary.cjs.map +1 -1
- package/dist/common/pl_binary.d.ts +7 -1
- package/dist/common/pl_binary.d.ts.map +1 -1
- package/dist/common/pl_binary.js +10 -2
- package/dist/common/pl_binary.js.map +1 -1
- package/dist/common/pl_binary_download.cjs +16 -16
- package/dist/common/pl_binary_download.cjs.map +1 -1
- package/dist/common/pl_binary_download.d.ts +26 -4
- package/dist/common/pl_binary_download.d.ts.map +1 -1
- package/dist/common/pl_binary_download.js +16 -16
- package/dist/common/pl_binary_download.js.map +1 -1
- package/dist/local/pl.cjs +25 -2
- package/dist/local/pl.cjs.map +1 -1
- package/dist/local/pl.d.ts +7 -0
- package/dist/local/pl.d.ts.map +1 -1
- package/dist/local/pl.js +25 -2
- package/dist/local/pl.js.map +1 -1
- package/dist/ssh/pl.cjs +8 -1
- package/dist/ssh/pl.cjs.map +1 -1
- package/dist/ssh/pl.d.ts.map +1 -1
- package/dist/ssh/pl.js +8 -1
- package/dist/ssh/pl.js.map +1 -1
- package/package.json +9 -7
- package/src/common/pl_binary.ts +16 -4
- package/src/common/pl_binary_download.ts +39 -27
- package/src/local/pl.ts +35 -4
- package/src/ssh/__tests__/pl-docker.test.ts +24 -21
- package/src/ssh/pl.ts +6 -5
package/dist/local/pl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.d.ts","sourceRoot":"","sources":["../../src/local/pl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"pl.d.ts","sourceRoot":"","sources":["../../src/local/pl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAOhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAA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AAO,CAAC,CAsEjG;AA4BD;mDACmD;AACnD,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CA6BvF;AAED;mDACmD;AACnD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,GAAG,EACf,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,kBAAkB,EACvB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAC7C,cAAc,CAqBhB"}
|
package/dist/local/pl.js
CHANGED
|
@@ -6,6 +6,8 @@ import { withTrace } from './trace.js';
|
|
|
6
6
|
import upath from 'upath';
|
|
7
7
|
import fsp from 'node:fs/promises';
|
|
8
8
|
import * as os from 'node:os';
|
|
9
|
+
import { defaultHttpDispatcher } from '@milaboratories/pl-http';
|
|
10
|
+
import { parseHttpAuth } from '@milaboratories/helpers';
|
|
9
11
|
|
|
10
12
|
const LocalConfigYaml = 'config-local.yaml';
|
|
11
13
|
/**
|
|
@@ -115,9 +117,30 @@ async function localPlatformaInit(logger, _ops) {
|
|
|
115
117
|
logger.info(`writing configuration '${configPath}'...`);
|
|
116
118
|
await fsp.writeFile(configPath, ops.config);
|
|
117
119
|
const plBinPath = upath.join(workDir, 'binaries');
|
|
118
|
-
const baseBinaryPath = await resolveLocalPlBinaryPath(
|
|
120
|
+
const baseBinaryPath = await resolveLocalPlBinaryPath({
|
|
121
|
+
logger,
|
|
122
|
+
downloadDir: plBinPath,
|
|
123
|
+
src: ops.plBinary,
|
|
124
|
+
dispatcher: defaultHttpDispatcher(ops.proxy),
|
|
125
|
+
});
|
|
119
126
|
const binaryPath = trace('binaryPath', upath.join('binaries', baseBinaryPath));
|
|
120
|
-
const
|
|
127
|
+
const env = { ...process.env };
|
|
128
|
+
if (ops.proxy?.url) {
|
|
129
|
+
const url = new URL(ops.proxy.url);
|
|
130
|
+
if (ops.proxy.auth) {
|
|
131
|
+
const parsed = parseHttpAuth(ops.proxy.auth);
|
|
132
|
+
if (parsed.scheme !== 'Basic') {
|
|
133
|
+
throw new Error(`\
|
|
134
|
+
Unsupported auth scheme: ${parsed.scheme}. \
|
|
135
|
+
Only Basic auth is supported by the backend.`);
|
|
136
|
+
}
|
|
137
|
+
url.username = parsed.username;
|
|
138
|
+
url.password = parsed.password;
|
|
139
|
+
}
|
|
140
|
+
env.http_proxy = url.toString();
|
|
141
|
+
env.https_proxy = url.toString();
|
|
142
|
+
}
|
|
143
|
+
const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, env);
|
|
121
144
|
trace('processOpts', {
|
|
122
145
|
cmd: processOpts.cmd,
|
|
123
146
|
args: processOpts.args,
|
package/dist/local/pl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.js","sources":["../../src/local/pl.ts"],"sourcesContent":["import type {\n ProcessOptions } from './process';\nimport {\n isProcessAlive,\n processStop,\n processWaitStopped,\n processRun,\n} 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';\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 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(logger, plBinPath, ops.plBinary);\n const binaryPath = trace('binaryPath', upath.join('binaries', baseBinaryPath));\n\n const processOpts = plProcessOps(binaryPath, configPath, ops, workDir, process.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 (_e) {\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":[],"mappings":";;;;;;;;;AAqBO,MAAM,eAAe,GAAG;AAE/B;;;;AAIG;MACU,OAAO,CAAA;AAQC,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,mBAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,eAAA;AACA,IAAA,qBAAA;AAdX,IAAA,QAAQ;AACT,IAAA,GAAG;IACF,KAAK,GAAW,CAAC;IACjB,cAAc,GAAU,EAAE;IAC1B,UAAU,GAAG,KAAK;AAE1B,IAAA,WAAA,CACmB,MAAgB,EAChB,UAAkB,EAClB,YAA4B,EAC5B,mBAA0B,EAC1B,OAAwC,EACxC,OAAwC,EACxC,eAAgD,EAChD,qBAAsD,EAAA;QAPtD,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,YAAY,GAAZ,YAAY;QACZ,IAAA,CAAA,mBAAmB,GAAnB,mBAAmB;QACnB,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,eAAe,GAAf,eAAe;QACf,IAAA,CAAA,qBAAqB,GAArB,qBAAqB;IACrC;AAEH,IAAA,MAAM,KAAK,GAAA;AACT,QAAA,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,CAAC,KAAI;AAC9C,YAAA,IAAI,CAA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AC9B,QAAA,IAAI,EAAE;AACJ,YAAA,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE;AACtB,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;YACpC,WAAW,EAAE,IAAI;AAClB,SAAA;KACF;AAED,IAAA,IAAI,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE;IACnE;IAEA,MAAM,UAAU,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,KAAK,CAAC;AACxB,IAAA,MAAM,CAAC,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,EAAE;AAE/C,IAAA,OAAO,MAAM;AACf;;;;"}
|
|
1
|
+
{"version":3,"file":"pl.js","sources":["../../src/local/pl.ts"],"sourcesContent":["import type { ProcessOptions } from './process';\nimport {\n isProcessAlive,\n processStop,\n processWaitStopped,\n processRun,\n} 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/helpers';\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 (_e) {\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":[],"mappings":";;;;;;;;;;;AAuBO,MAAM,eAAe,GAAG;AAE/B;;;;AAIG;MACU,OAAO,CAAA;AAQC,IAAA,MAAA;AACA,IAAA,UAAA;AACA,IAAA,YAAA;AACA,IAAA,mBAAA;AACA,IAAA,OAAA;AACA,IAAA,OAAA;AACA,IAAA,eAAA;AACA,IAAA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AAc,CAAC;AAEtC,IAAA,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,eAAe,EAAE;AAC1C;AAEA;AACmD;AAC7C,SAAU,YAAY,CAC1B,UAAe,EACf,UAAkB,EAClB,GAAuB,EACvB,OAAe,EACf,UAA8C,EAAA;AAE9C,IAAA,MAAM,MAAM,GAAmB;AAC7B,QAAA,GAAG,EAAE,UAAU;AACf,QAAA,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;AAC9B,QAAA,IAAI,EAAE;AACJ,YAAA,GAAG,EAAE,EAAE,GAAG,UAAU,EAAE;AACtB,YAAA,GAAG,EAAE,OAAO;AACZ,YAAA,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;YACpC,WAAW,EAAE,IAAI;AAClB,SAAA;KACF;AAED,IAAA,IAAI,GAAG,CAAC,YAAY,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE;IACnE;IAEA,MAAM,UAAU,GAAG,EAAE,GAAG,GAAG,CAAC,YAAY,EAAE;AAC1C,IAAA,OAAO,UAAU,CAAC,KAAK,CAAC;AACxB,IAAA,MAAM,CAAC,IAAI,GAAG,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,UAAU,EAAE;AAE/C,IAAA,OAAO,MAAM;AACf;;;;"}
|
package/dist/ssh/pl.cjs
CHANGED
|
@@ -338,7 +338,14 @@ class SshPl {
|
|
|
338
338
|
const attempts = 5;
|
|
339
339
|
for (let i = 1; i <= attempts; i++) {
|
|
340
340
|
try {
|
|
341
|
-
downloadBinaryResult = await pl_binary_download.downloadBinaryNoExtract(
|
|
341
|
+
downloadBinaryResult = await pl_binary_download.downloadBinaryNoExtract({
|
|
342
|
+
logger: this.logger,
|
|
343
|
+
baseDir: localWorkdir,
|
|
344
|
+
softwareName,
|
|
345
|
+
tgzName,
|
|
346
|
+
arch: arch.arch,
|
|
347
|
+
platform: arch.platform,
|
|
348
|
+
});
|
|
342
349
|
break;
|
|
343
350
|
}
|
|
344
351
|
catch (e) {
|
package/dist/ssh/pl.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pl.cjs","sources":["../../src/ssh/pl.ts"],"sourcesContent":["import type * as ssh from 'ssh2';\nimport { SshClient } from './ssh';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { sleep, notEmpty } from '@milaboratories/ts-helpers';\nimport type { DownloadBinaryResult } from '../common/pl_binary_download';\nimport { downloadBinaryNoExtract } from '../common/pl_binary_download';\nimport upath from 'upath';\nimport * as plpath from './pl_paths';\nimport { getDefaultPlVersion } from '../common/pl_version';\n\nimport net from 'node:net';\nimport type { PlConfig, PlLicenseMode, SshPlConfigGenerationResult } from '@milaboratories/pl-config';\nimport { getFreePort, generateSshPlConfigs } from '@milaboratories/pl-config';\nimport type { SupervisorStatus } from './supervisord';\nimport { supervisorStatus, supervisorStop as supervisorCtlShutdown, generateSupervisordConfigWithMinio, supervisorCtlStart, isSupervisordRunning, generateSupervisordConfig, isAllAlive } from './supervisord';\nimport type { ConnectionInfo, SshPlPorts } from './connection_info';\nimport { newConnectionInfo, parseConnectionInfo, stringifyConnectionInfo } from './connection_info';\nimport type { PlBinarySourceDownload } from '../common/pl_binary';\n\nconst minRequiredGlibcVersion = 2.28;\n\nexport class SshPl {\n private initState: PlatformaInitState = { step: 'init' };\n constructor(\n public readonly logger: MiLogger,\n public readonly sshClient: SshClient,\n private readonly username: string,\n ) { }\n\n public info() {\n return {\n username: this.username,\n initState: this.initState,\n };\n }\n\n public static async init(logger: MiLogger, config: ssh.ConnectConfig): Promise<SshPl> {\n try {\n const sshClient = await SshClient.init(logger, config);\n return new SshPl(logger, sshClient, notEmpty(config.username));\n } catch (e: unknown) {\n logger.error(`Connection error in SshClient.init: ${e}`);\n throw e;\n }\n }\n\n public cleanUp() {\n this.sshClient.close();\n }\n\n /** Provides an info if the platforma and minio are running along with the debug info. */\n public async isAlive(): Promise<SupervisorStatus> {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n return await supervisorStatus(this.logger, this.sshClient, remoteHome, arch.arch);\n }\n\n /** Starts all the services on the server.\n * Idempotent semantic: we could call it several times. */\n public async start(shouldUseMinio: boolean) {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n\n try {\n if (!isAllAlive(await this.isAlive(), shouldUseMinio)) {\n await supervisorCtlStart(this.sshClient, remoteHome, arch.arch);\n\n // We are waiting for Platforma to run to ensure that it has started.\n return await this.checkIsAliveWithInterval(shouldUseMinio);\n }\n } catch (e: unknown) {\n let msg = `SshPl.start: ${e}`;\n\n let logs = '';\n try {\n logs = await this.sshClient.readFile(plpath.platformaCliLogs(remoteHome));\n msg += `, platforma cli logs: ${logs}`;\n } catch (e: unknown) {\n msg += `, Can not read platforma cli logs: ${e}`;\n }\n\n this.logger.error(msg);\n throw new Error(msg);\n }\n }\n\n /** Stops all the services on the server.\n * Idempotent semantic: we could call it several times. */\n public async stop() {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n\n try {\n const alive = await this.isAlive();\n if (isSupervisordRunning(alive)) {\n await supervisorCtlShutdown(this.sshClient, remoteHome, arch.arch);\n // Check if Minio is running by looking at the alive status\n const shouldUseMinio = alive.minio === true;\n return await this.checkIsAliveWithInterval(shouldUseMinio, 1000, 15, false);\n }\n } catch (e: unknown) {\n const msg = `PlSsh.stop: ${e}`;\n this.logger.error(msg);\n throw new Error(msg);\n }\n }\n\n /** Stops the services, deletes a directory with the state and closes SSH connection. */\n public async reset(): Promise<boolean> {\n await this.stopAndClean();\n this.cleanUp();\n return true;\n }\n\n /** Stops platforma and deletes its state. */\n public async stopAndClean(): Promise<void> {\n const remoteHome = await this.getUserHomeDirectory();\n\n this.logger.info(`pl.reset: Stop Platforma on the server`);\n await this.stop();\n\n this.logger.info(`pl.reset: Deleting Platforma workDir ${plpath.workDir(remoteHome)} on the server`);\n await this.sshClient.deleteFolder(plpath.workDir(remoteHome));\n }\n\n /** Downloads binaries and untar them on the server,\n * generates all the configs, creates necessary dirs,\n * and finally starts all the services. */\n public async platformaInit(options: SshPlConfig): Promise<ConnectionInfo> {\n const state: PlatformaInitState = { localWorkdir: options.localWorkdir, step: 'init' };\n\n const { onProgress } = options;\n\n // merge options with default ops.\n const ops: SshPlConfig = {\n ...defaultSshPlConfig,\n ...options,\n };\n state.plBinaryOps = ops.plBinary;\n\n try {\n await this.doStepDetectArch(state, onProgress);\n await this.doStepDetectHome(state, onProgress);\n\n const needRestartPlatforma = await this.doStepReadExistedConfig(state, ops, onProgress);\n if (!needRestartPlatforma) {\n await onProgress?.('Platforma is already running. Skipping initialization.');\n return state.existedSettings!;\n }\n await this.doStepStopExistedPlatforma(state, onProgress);\n\n await onProgress?.('Installation platforma...');\n\n await this.doStepDownloadBinaries(state, onProgress, ops);\n await this.doStepFetchPorts(state);\n await this.doStepGenerateNewConfig(state, onProgress, ops);\n await this.doStepCreateFoldersAndSaveFiles(state, onProgress);\n await this.doStepConfigureSupervisord(state, onProgress);\n await this.doStepSaveNewConnectionInfo(state, onProgress, ops);\n await this.doStepStartPlatforma(state, onProgress);\n\n return state.connectionInfo!;\n } catch (e: unknown) {\n const msg = `SshPl.platformaInit: ${e}, state: ${JSON.stringify(this.removeSensitiveData(state))}`;\n this.logger.error(msg);\n\n throw new Error(msg);\n }\n }\n\n private async doStepStopExistedPlatforma(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'stopExistedPlatforma';\n if (!isAllAlive(state.alive!, state.shouldUseMinio ?? false)) {\n return;\n }\n\n await onProgress?.('Stopping services...');\n await this.stop();\n }\n\n private removeSensitiveData(state: PlatformaInitState): PlatformaInitState {\n const stateCopy = { ...state };\n stateCopy.generatedConfig = { ...stateCopy.generatedConfig, filesToCreate: { skipped: 'sanitized' } } as SshPlConfigGenerationResult;\n return stateCopy;\n }\n\n private async doStepStartPlatforma(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'startPlatforma';\n await onProgress?.('Starting Platforma on the server...');\n await this.start(state.shouldUseMinio ?? false);\n state.started = true;\n this.initState = state;\n\n await onProgress?.('Platforma has been started successfully.');\n }\n\n private async doStepSaveNewConnectionInfo(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'saveNewConnectionInfo';\n const config = state.generatedConfig!;\n await onProgress?.('Saving connection information...');\n state.connectionInfo = newConnectionInfo(\n config.plUser,\n config.plPassword,\n state.ports!,\n notEmpty(ops.useGlobalAccess),\n ops.plBinary!.version,\n state.shouldUseMinio ?? false,\n );\n await this.sshClient.writeFileOnTheServer(\n plpath.connectionInfo(state.remoteHome!),\n stringifyConnectionInfo(state.connectionInfo),\n );\n await onProgress?.('Connection information saved.');\n }\n\n private async doStepConfigureSupervisord(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n await onProgress?.('Writing supervisord configuration...');\n state.step = 'configureSupervisord';\n\n const config = state.generatedConfig!;\n\n let supervisorConfig: string;\n if (state.shouldUseMinio) {\n supervisorConfig = generateSupervisordConfigWithMinio(\n config.minioConfig.storageDir,\n config.minioConfig.envs,\n await this.getFreePortForPlatformaOnServer(state.remoteHome!, state.arch!),\n config.workingDir,\n config.plConfig.configPath,\n state.binPaths!.minioRelPath!,\n state.binPaths!.downloadedPl,\n );\n } else {\n supervisorConfig = generateSupervisordConfig(\n await this.getFreePortForPlatformaOnServer(state.remoteHome!, state.arch!),\n config.workingDir,\n config.plConfig.configPath,\n state.binPaths!.downloadedPl,\n );\n }\n\n const writeResult = await this.sshClient.writeFileOnTheServer(plpath.supervisorConf(state.remoteHome!), supervisorConfig);\n if (!writeResult) {\n throw new Error(`Can not write supervisord config on the server ${plpath.workDir(state.remoteHome!)}`);\n }\n await onProgress?.('Supervisord configuration written.');\n }\n\n private async doStepCreateFoldersAndSaveFiles(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'createFoldersAndSaveFiles';\n const config = state.generatedConfig!;\n await onProgress?.('Generating folder structure...');\n for (const [filePath, content] of Object.entries(config.filesToCreate)) {\n await this.sshClient.writeFileOnTheServer(filePath, content);\n this.logger.info(`Created file ${filePath}`);\n }\n\n for (const dir of config.dirsToCreate) {\n await this.sshClient.ensureRemoteDirCreated(dir);\n this.logger.info(`Created directory ${dir}`);\n }\n await onProgress?.('Folder structure created.');\n }\n\n private async doStepGenerateNewConfig(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'generateNewConfig';\n\n await onProgress?.('Generating new config...');\n const config = await generateSshPlConfigs({\n logger: this.logger,\n workingDir: plpath.workDir(state.remoteHome!),\n portsMode: {\n type: 'customWithMinio',\n ports: {\n debug: state.ports!.debug.remote,\n grpc: state.ports!.grpc.remote,\n http: state.ports!.http!.remote,\n minio: state.ports!.minioPort.remote,\n minioConsole: state.ports!.minioConsolePort.remote,\n monitoring: state.ports!.monitoring.remote,\n\n httpLocal: state.ports!.http!.local,\n grpcLocal: state.ports!.grpc.local,\n minioLocal: state.ports!.minioPort.local,\n },\n },\n licenseMode: ops.license,\n useGlobalAccess: notEmpty(ops.useGlobalAccess),\n plConfigPostprocessing: ops.plConfigPostprocessing,\n useMinio: state.shouldUseMinio ?? false,\n });\n state.generatedConfig = { ...config };\n await onProgress?.('New config generated');\n }\n\n private async doStepFetchPorts(state: PlatformaInitState) {\n state.step = 'fetchPorts';\n state.ports = await this.fetchPorts(state.remoteHome!, state.arch!);\n\n if (!state.ports.debug.remote\n || !state.ports.grpc.remote\n || !state.ports.minioPort.remote\n || !state.ports.minioConsolePort.remote\n || !state.ports.monitoring.remote\n || !state.ports.http?.remote) {\n throw new Error(`SshPl.platformaInit: remote ports are not defined`);\n }\n }\n\n private async doStepDownloadBinaries(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'downloadBinaries';\n await onProgress?.('Downloading and uploading required binaries...');\n\n const glibcVersion = await getGlibcVersion(this.logger, this.sshClient);\n if (glibcVersion < minRequiredGlibcVersion)\n throw new Error(`glibc version ${glibcVersion} is too old. Version ${minRequiredGlibcVersion} or higher is required for Platforma.`);\n\n const downloadRes = await this.downloadBinariesAndUploadToTheServer(\n ops.localWorkdir, ops.plBinary!, state.remoteHome!, state.arch!, state.shouldUseMinio ?? false,\n );\n await onProgress?.('All required binaries have been downloaded and uploaded.');\n\n state.binPaths = { ...downloadRes, history: undefined };\n state.downloadedBinaries = downloadRes.history;\n }\n\n private async doStepDetectArch(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'detectArch';\n await onProgress?.('Detecting server architecture...');\n state.arch = await this.getArch();\n await onProgress?.('Server architecture detected.');\n }\n\n private async doStepDetectHome(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'detectHome';\n await onProgress?.('Fetching user home directory...');\n state.remoteHome = await this.getUserHomeDirectory();\n await onProgress?.('User home directory retrieved.');\n }\n\n private async doStepReadExistedConfig(\n state: PlatformaInitState,\n ops: SshPlConfig,\n onProgress: ((...args: any) => Promise<any>) | undefined,\n ): Promise<boolean> {\n state.step = 'checkAlive';\n await onProgress?.('Checking platform status...');\n state.alive = await this.isAlive();\n\n if (!state.alive?.platforma) {\n return true;\n }\n\n await onProgress?.('All required services are running.');\n\n state.existedSettings = await this.readExistedConfig(state.remoteHome!);\n if (!state.existedSettings) {\n throw new Error(`SshPl.platformaInit: platforma is alive but existed settings are not found`);\n }\n\n const sameGA = state.existedSettings.useGlobalAccess == ops.useGlobalAccess;\n const samePlVersion = state.existedSettings.plVersion == ops.plBinary!.version;\n state.needRestart = !(sameGA && samePlVersion);\n this.logger.info(`SshPl.platformaInit: need restart? ${state.needRestart}`);\n\n state.shouldUseMinio = state.existedSettings.minioIsUsed;\n if (state.shouldUseMinio) {\n this.logger.info(`SshPl.platformaInit: minio is used`);\n } else {\n this.logger.info(`SshPl.platformaInit: minio is not used`);\n }\n\n if (!state.needRestart) {\n await onProgress?.('Server setup completed.');\n return false;\n }\n\n await onProgress?.('Stopping services...');\n await this.stop();\n\n return true;\n }\n\n public async downloadBinariesAndUploadToTheServer(\n localWorkdir: string,\n plBinary: PlBinarySourceDownload,\n remoteHome: string,\n arch: Arch,\n shouldUseMinio: boolean,\n ) {\n const state: DownloadAndUntarState[] = [];\n try {\n const pl = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'pl', `pl-${plBinary.version}`,\n );\n state.push(pl);\n\n const supervisor = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'supervisord', plpath.supervisordDirName,\n );\n state.push(supervisor);\n\n const minioPath = plpath.minioBin(remoteHome, arch.arch);\n if (shouldUseMinio) {\n const minio = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'minio', plpath.minioDirName,\n );\n state.push(minio);\n await this.sshClient.chmod(minioPath, 0o750);\n }\n\n return {\n history: state,\n minioRelPath: shouldUseMinio ? minioPath : undefined,\n downloadedPl: plpath.platformaBin(remoteHome, arch.arch),\n };\n } catch (e: unknown) {\n const msg = `SshPl.downloadBinariesAndUploadToServer: ${e}, state: ${JSON.stringify(state)}`;\n this.logger.error(msg);\n throw e;\n }\n }\n\n /** We have to extract pl in the remote server,\n * because Windows doesn't support symlinks\n * that are found in Linux pl binaries tgz archive.\n * For this reason, we extract all to the remote server.\n * It requires `tar` to be installed on the server\n * (it's not installed for Rocky Linux for example). */\n public async downloadAndUntar(\n localWorkdir: string,\n remoteHome: string,\n arch: Arch,\n softwareName: string,\n tgzName: string,\n ): Promise<DownloadAndUntarState> {\n const state: DownloadAndUntarState = {};\n state.binBasePath = plpath.binariesDir(remoteHome);\n await this.sshClient.ensureRemoteDirCreated(state.binBasePath);\n state.binBasePathCreated = true;\n\n let downloadBinaryResult: DownloadBinaryResult | null = null;\n const attempts = 5;\n for (let i = 1; i <= attempts; i++) {\n try {\n downloadBinaryResult = await downloadBinaryNoExtract(\n this.logger,\n localWorkdir,\n softwareName,\n tgzName,\n arch.arch, arch.platform,\n );\n break;\n } catch (e: unknown) {\n await sleep(300);\n if (i == attempts) {\n throw new Error(`downloadAndUntar: ${attempts} attempts, last error: ${e}`);\n }\n }\n }\n state.downloadResult = notEmpty(downloadBinaryResult);\n\n state.localArchivePath = upath.resolve(state.downloadResult.archivePath);\n state.remoteDir = upath.join(state.binBasePath, state.downloadResult.baseName);\n state.remoteArchivePath = state.remoteDir + '.tgz';\n\n await this.sshClient.ensureRemoteDirCreated(state.remoteDir);\n await this.sshClient.uploadFile(state.localArchivePath, state.remoteArchivePath);\n state.uploadDone = true;\n\n try {\n await this.sshClient.exec('hash tar');\n } catch (_) {\n throw new Error(`tar is not installed on the server. Please install it before running Platforma.`);\n }\n\n // TODO: Create a proper archive to avoid xattr warnings\n const untarResult = await this.sshClient.exec(\n `tar --warning=no-all -xvf ${state.remoteArchivePath} --directory=${state.remoteDir}`,\n );\n\n if (untarResult.stderr)\n throw new Error(`downloadAndUntar: untar: stderr occurred: ${untarResult.stderr}, stdout: ${untarResult.stdout}`);\n\n state.untarDone = true;\n\n return state;\n }\n\n public async needDownload(remoteHome: string, arch: Arch) {\n const checkPathSupervisor = plpath.supervisorBin(remoteHome, arch.arch);\n const checkPathMinio = plpath.minioDir(remoteHome, arch.arch);\n const checkPathPlatforma = plpath.platformaBin(remoteHome, arch.arch);\n\n if (!await this.sshClient.checkFileExists(checkPathPlatforma)\n || !await this.sshClient.checkFileExists(checkPathMinio)\n || !await this.sshClient.checkFileExists(checkPathSupervisor)) {\n return true;\n }\n\n return false;\n }\n\n public async checkIsAliveWithInterval(shouldUseMinio: boolean, interval: number = 1000, count = 15, shouldStart = true): Promise<void> {\n const maxMs = count * interval;\n\n let total = 0;\n let alive = await this.isAlive();\n while (shouldStart ? !isAllAlive(alive, shouldUseMinio) : isAllAlive(alive, shouldUseMinio)) {\n await sleep(interval);\n total += interval;\n if (total > maxMs) {\n throw new Error(`isAliveWithInterval: The process did not ${shouldStart ? 'started' : 'stopped'} after ${maxMs} ms. Live status: ${JSON.stringify(alive)}`);\n }\n alive = await this.isAlive();\n }\n }\n\n public async readExistedConfig(remoteHome: string): Promise<ConnectionInfo> {\n const connectionInfo = await this.sshClient.readFile(plpath.connectionInfo(remoteHome));\n return parseConnectionInfo(connectionInfo);\n }\n\n public async fetchPorts(remoteHome: string, arch: Arch): Promise<SshPlPorts> {\n const ports: SshPlPorts = {\n grpc: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n monitoring: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n debug: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n http: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n minioPort: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n minioConsolePort: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n };\n\n return ports;\n }\n\n public async getLocalFreePort(): Promise<number> {\n return new Promise((res) => {\n const srv = net.createServer();\n srv.listen(0, () => {\n const port = (srv.address() as net.AddressInfo).port;\n srv.close((_) => res(port));\n });\n });\n }\n\n public async getFreePortForPlatformaOnServer(remoteHome: string, arch: Arch): Promise<number> {\n const freePortBin = plpath.platformaFreePortBin(remoteHome, arch.arch);\n\n const { stdout, stderr } = await this.sshClient.exec(`${freePortBin}`);\n if (stderr) {\n throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${stderr}, stdout: ${stdout}`);\n }\n\n return +stdout;\n }\n\n public async getArch(): Promise<Arch> {\n const { stdout, stderr } = await this.sshClient.exec('uname -s && uname -m');\n if (stderr)\n throw new Error(`getArch: stderr is not empty: ${stderr}, stdout: ${stdout}`);\n\n const arr = stdout.split('\\n');\n\n return {\n platform: arr[0],\n arch: arr[1],\n };\n }\n\n public async getUserHomeDirectory() {\n const { stdout, stderr } = await this.sshClient.exec('echo $HOME');\n\n if (stderr) {\n const home = `/home/${this.username}`;\n console.warn(`getUserHomeDirectory: stderr is not empty: ${stderr}, stdout: ${stdout}, will get a default home: ${home}`);\n\n return home;\n }\n\n return stdout.trim();\n }\n}\n\ntype Arch = { platform: string; arch: string };\n\nexport type SshPlConfig = {\n localWorkdir: string;\n license: PlLicenseMode;\n useGlobalAccess?: boolean;\n plBinary?: PlBinarySourceDownload;\n\n onProgress?: (...args: any) => Promise<any>;\n plConfigPostprocessing?: (config: PlConfig) => PlConfig;\n};\n\nconst defaultSshPlConfig: Pick<\n SshPlConfig,\n | 'useGlobalAccess'\n | 'plBinary'\n> = {\n useGlobalAccess: false,\n plBinary: {\n type: 'Download',\n version: getDefaultPlVersion(),\n },\n};\n\ntype BinPaths = {\n history?: DownloadAndUntarState[];\n minioRelPath?: string;\n downloadedPl: string;\n};\n\ntype DownloadAndUntarState = {\n binBasePath?: string;\n binBasePathCreated?: boolean;\n downloadResult?: DownloadBinaryResult;\n attempts?: number;\n\n localArchivePath?: string;\n remoteDir?: string;\n remoteArchivePath?: string;\n uploadDone?: boolean;\n untarDone?: boolean;\n};\n\ntype PlatformaInitStep =\n 'init'\n | 'detectArch'\n | 'detectHome'\n | 'checkAlive'\n | 'stopExistedPlatforma'\n | 'downloadBinaries'\n | 'fetchPorts'\n | 'generateNewConfig'\n | 'createFoldersAndSaveFiles'\n | 'configureSupervisord'\n | 'saveNewConnectionInfo'\n | 'startPlatforma';\n\ntype PlatformaInitState = {\n step: PlatformaInitStep;\n localWorkdir?: string;\n plBinaryOps?: PlBinarySourceDownload;\n arch?: Arch;\n remoteHome?: string;\n alive?: SupervisorStatus;\n existedSettings?: ConnectionInfo;\n needRestart?: boolean;\n shouldUseMinio?: boolean;\n downloadedBinaries?: DownloadAndUntarState[];\n binPaths?: BinPaths;\n ports?: SshPlPorts;\n generatedConfig?: SshPlConfigGenerationResult;\n connectionInfo?: ConnectionInfo;\n started?: boolean;\n};\n\n/**\n * Gets the glibc version on the remote system\n * @returns The glibc version as a number\n * @throws Error if version cannot be determined\n */\nasync function getGlibcVersion(logger: MiLogger, sshClient: SshClient): Promise <number> {\n try {\n const { stdout, stderr } = await sshClient.exec('ldd --version | head -n 1');\n if (stderr) {\n throw new Error(`Failed to check glibc version: ${stderr}`);\n }\n return parseGlibcVersion(stdout);\n } catch (e: unknown) {\n logger.error(`glibc version check failed: ${e}`);\n throw e;\n }\n}\n\nexport function parseGlibcVersion(output: string): number {\n const versionMatch = output.match(/\\d+\\.\\d+/);\n if (!versionMatch) {\n throw new Error(`Could not parse glibc version from: ${output}`);\n }\n\n return parseFloat(versionMatch[0]);\n}\n"],"names":["SshClient","notEmpty","supervisorStatus","isAllAlive","supervisorCtlStart","plpath.platformaCliLogs","isSupervisordRunning","supervisorCtlShutdown","plpath.workDir","newConnectionInfo","plpath.connectionInfo","stringifyConnectionInfo","generateSupervisordConfigWithMinio","generateSupervisordConfig","plpath.supervisorConf","generateSshPlConfigs","plpath.supervisordDirName","plpath.minioBin","plpath.minioDirName","plpath.platformaBin","plpath.binariesDir","downloadBinaryNoExtract","sleep","plpath.supervisorBin","plpath.minioDir","parseConnectionInfo","getFreePort","plpath.platformaFreePortBin","getDefaultPlVersion"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,uBAAuB,GAAG,IAAI;MAEvB,KAAK,CAAA;AAGE,IAAA,MAAA;AACA,IAAA,SAAA;AACC,IAAA,QAAA;AAJX,IAAA,SAAS,GAAuB,EAAE,IAAI,EAAE,MAAM,EAAE;AACxD,IAAA,WAAA,CACkB,MAAgB,EAChB,SAAoB,EACnB,QAAgB,EAAA;QAFjB,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,SAAS,GAA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BAA2B,CAAC;QAC5E,IAAI,MAAM,EAAE;AACV,YAAA,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAA,CAAE,CAAC;QAC7D;AACA,QAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC;IAClC;IAAE,OAAO,CAAU,EAAE;AACnB,QAAA,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA,CAAE,CAAC;AAChD,QAAA,MAAM,CAAC;IACT;AACF;AAEM,SAAU,iBAAiB,CAAC,MAAc,EAAA;IAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;IAC7C,IAAI,CAAC,YAAY,EAAE;AACjB,QAAA,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,CAAA,CAAE,CAAC;IAClE;AAEA,IAAA,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;AACpC;;;;;"}
|
|
1
|
+
{"version":3,"file":"pl.cjs","sources":["../../src/ssh/pl.ts"],"sourcesContent":["import type * as ssh from 'ssh2';\nimport { SshClient } from './ssh';\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport { sleep, notEmpty } from '@milaboratories/ts-helpers';\nimport type { DownloadBinaryResult } from '../common/pl_binary_download';\nimport { downloadBinaryNoExtract } from '../common/pl_binary_download';\nimport upath from 'upath';\nimport * as plpath from './pl_paths';\nimport { getDefaultPlVersion } from '../common/pl_version';\n\nimport net from 'node:net';\nimport type { PlConfig, PlLicenseMode, SshPlConfigGenerationResult } from '@milaboratories/pl-config';\nimport { getFreePort, generateSshPlConfigs } from '@milaboratories/pl-config';\nimport type { SupervisorStatus } from './supervisord';\nimport { supervisorStatus, supervisorStop as supervisorCtlShutdown, generateSupervisordConfigWithMinio, supervisorCtlStart, isSupervisordRunning, generateSupervisordConfig, isAllAlive } from './supervisord';\nimport type { ConnectionInfo, SshPlPorts } from './connection_info';\nimport { newConnectionInfo, parseConnectionInfo, stringifyConnectionInfo } from './connection_info';\nimport type { PlBinarySourceDownload } from '../common/pl_binary';\n\nconst minRequiredGlibcVersion = 2.28;\n\nexport class SshPl {\n private initState: PlatformaInitState = { step: 'init' };\n constructor(\n public readonly logger: MiLogger,\n public readonly sshClient: SshClient,\n private readonly username: string,\n ) { }\n\n public info() {\n return {\n username: this.username,\n initState: this.initState,\n };\n }\n\n public static async init(logger: MiLogger, config: ssh.ConnectConfig): Promise<SshPl> {\n try {\n const sshClient = await SshClient.init(logger, config);\n return new SshPl(logger, sshClient, notEmpty(config.username));\n } catch (e: unknown) {\n logger.error(`Connection error in SshClient.init: ${e}`);\n throw e;\n }\n }\n\n public cleanUp() {\n this.sshClient.close();\n }\n\n /** Provides an info if the platforma and minio are running along with the debug info. */\n public async isAlive(): Promise<SupervisorStatus> {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n return await supervisorStatus(this.logger, this.sshClient, remoteHome, arch.arch);\n }\n\n /** Starts all the services on the server.\n * Idempotent semantic: we could call it several times. */\n public async start(shouldUseMinio: boolean) {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n\n try {\n if (!isAllAlive(await this.isAlive(), shouldUseMinio)) {\n await supervisorCtlStart(this.sshClient, remoteHome, arch.arch);\n\n // We are waiting for Platforma to run to ensure that it has started.\n return await this.checkIsAliveWithInterval(shouldUseMinio);\n }\n } catch (e: unknown) {\n let msg = `SshPl.start: ${e}`;\n\n let logs = '';\n try {\n logs = await this.sshClient.readFile(plpath.platformaCliLogs(remoteHome));\n msg += `, platforma cli logs: ${logs}`;\n } catch (e: unknown) {\n msg += `, Can not read platforma cli logs: ${e}`;\n }\n\n this.logger.error(msg);\n throw new Error(msg);\n }\n }\n\n /** Stops all the services on the server.\n * Idempotent semantic: we could call it several times. */\n public async stop() {\n const arch = await this.getArch();\n const remoteHome = await this.getUserHomeDirectory();\n\n try {\n const alive = await this.isAlive();\n if (isSupervisordRunning(alive)) {\n await supervisorCtlShutdown(this.sshClient, remoteHome, arch.arch);\n // Check if Minio is running by looking at the alive status\n const shouldUseMinio = alive.minio === true;\n return await this.checkIsAliveWithInterval(shouldUseMinio, 1000, 15, false);\n }\n } catch (e: unknown) {\n const msg = `PlSsh.stop: ${e}`;\n this.logger.error(msg);\n throw new Error(msg);\n }\n }\n\n /** Stops the services, deletes a directory with the state and closes SSH connection. */\n public async reset(): Promise<boolean> {\n await this.stopAndClean();\n this.cleanUp();\n return true;\n }\n\n /** Stops platforma and deletes its state. */\n public async stopAndClean(): Promise<void> {\n const remoteHome = await this.getUserHomeDirectory();\n\n this.logger.info(`pl.reset: Stop Platforma on the server`);\n await this.stop();\n\n this.logger.info(`pl.reset: Deleting Platforma workDir ${plpath.workDir(remoteHome)} on the server`);\n await this.sshClient.deleteFolder(plpath.workDir(remoteHome));\n }\n\n /** Downloads binaries and untar them on the server,\n * generates all the configs, creates necessary dirs,\n * and finally starts all the services. */\n public async platformaInit(options: SshPlConfig): Promise<ConnectionInfo> {\n const state: PlatformaInitState = { localWorkdir: options.localWorkdir, step: 'init' };\n\n const { onProgress } = options;\n\n // merge options with default ops.\n const ops: SshPlConfig = {\n ...defaultSshPlConfig,\n ...options,\n };\n state.plBinaryOps = ops.plBinary;\n\n try {\n await this.doStepDetectArch(state, onProgress);\n await this.doStepDetectHome(state, onProgress);\n\n const needRestartPlatforma = await this.doStepReadExistedConfig(state, ops, onProgress);\n if (!needRestartPlatforma) {\n await onProgress?.('Platforma is already running. Skipping initialization.');\n return state.existedSettings!;\n }\n await this.doStepStopExistedPlatforma(state, onProgress);\n\n await onProgress?.('Installation platforma...');\n\n await this.doStepDownloadBinaries(state, onProgress, ops);\n await this.doStepFetchPorts(state);\n await this.doStepGenerateNewConfig(state, onProgress, ops);\n await this.doStepCreateFoldersAndSaveFiles(state, onProgress);\n await this.doStepConfigureSupervisord(state, onProgress);\n await this.doStepSaveNewConnectionInfo(state, onProgress, ops);\n await this.doStepStartPlatforma(state, onProgress);\n\n return state.connectionInfo!;\n } catch (e: unknown) {\n const msg = `SshPl.platformaInit: ${e}, state: ${JSON.stringify(this.removeSensitiveData(state))}`;\n this.logger.error(msg);\n\n throw new Error(msg);\n }\n }\n\n private async doStepStopExistedPlatforma(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'stopExistedPlatforma';\n if (!isAllAlive(state.alive!, state.shouldUseMinio ?? false)) {\n return;\n }\n\n await onProgress?.('Stopping services...');\n await this.stop();\n }\n\n private removeSensitiveData(state: PlatformaInitState): PlatformaInitState {\n const stateCopy = { ...state };\n stateCopy.generatedConfig = { ...stateCopy.generatedConfig, filesToCreate: { skipped: 'sanitized' } } as SshPlConfigGenerationResult;\n return stateCopy;\n }\n\n private async doStepStartPlatforma(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'startPlatforma';\n await onProgress?.('Starting Platforma on the server...');\n await this.start(state.shouldUseMinio ?? false);\n state.started = true;\n this.initState = state;\n\n await onProgress?.('Platforma has been started successfully.');\n }\n\n private async doStepSaveNewConnectionInfo(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'saveNewConnectionInfo';\n const config = state.generatedConfig!;\n await onProgress?.('Saving connection information...');\n state.connectionInfo = newConnectionInfo(\n config.plUser,\n config.plPassword,\n state.ports!,\n notEmpty(ops.useGlobalAccess),\n ops.plBinary!.version,\n state.shouldUseMinio ?? false,\n );\n await this.sshClient.writeFileOnTheServer(\n plpath.connectionInfo(state.remoteHome!),\n stringifyConnectionInfo(state.connectionInfo),\n );\n await onProgress?.('Connection information saved.');\n }\n\n private async doStepConfigureSupervisord(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n await onProgress?.('Writing supervisord configuration...');\n state.step = 'configureSupervisord';\n\n const config = state.generatedConfig!;\n\n let supervisorConfig: string;\n if (state.shouldUseMinio) {\n supervisorConfig = generateSupervisordConfigWithMinio(\n config.minioConfig.storageDir,\n config.minioConfig.envs,\n await this.getFreePortForPlatformaOnServer(state.remoteHome!, state.arch!),\n config.workingDir,\n config.plConfig.configPath,\n state.binPaths!.minioRelPath!,\n state.binPaths!.downloadedPl,\n );\n } else {\n supervisorConfig = generateSupervisordConfig(\n await this.getFreePortForPlatformaOnServer(state.remoteHome!, state.arch!),\n config.workingDir,\n config.plConfig.configPath,\n state.binPaths!.downloadedPl,\n );\n }\n\n const writeResult = await this.sshClient.writeFileOnTheServer(plpath.supervisorConf(state.remoteHome!), supervisorConfig);\n if (!writeResult) {\n throw new Error(`Can not write supervisord config on the server ${plpath.workDir(state.remoteHome!)}`);\n }\n await onProgress?.('Supervisord configuration written.');\n }\n\n private async doStepCreateFoldersAndSaveFiles(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'createFoldersAndSaveFiles';\n const config = state.generatedConfig!;\n await onProgress?.('Generating folder structure...');\n for (const [filePath, content] of Object.entries(config.filesToCreate)) {\n await this.sshClient.writeFileOnTheServer(filePath, content);\n this.logger.info(`Created file ${filePath}`);\n }\n\n for (const dir of config.dirsToCreate) {\n await this.sshClient.ensureRemoteDirCreated(dir);\n this.logger.info(`Created directory ${dir}`);\n }\n await onProgress?.('Folder structure created.');\n }\n\n private async doStepGenerateNewConfig(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'generateNewConfig';\n\n await onProgress?.('Generating new config...');\n const config = await generateSshPlConfigs({\n logger: this.logger,\n workingDir: plpath.workDir(state.remoteHome!),\n portsMode: {\n type: 'customWithMinio',\n ports: {\n debug: state.ports!.debug.remote,\n grpc: state.ports!.grpc.remote,\n http: state.ports!.http!.remote,\n minio: state.ports!.minioPort.remote,\n minioConsole: state.ports!.minioConsolePort.remote,\n monitoring: state.ports!.monitoring.remote,\n\n httpLocal: state.ports!.http!.local,\n grpcLocal: state.ports!.grpc.local,\n minioLocal: state.ports!.minioPort.local,\n },\n },\n licenseMode: ops.license,\n useGlobalAccess: notEmpty(ops.useGlobalAccess),\n plConfigPostprocessing: ops.plConfigPostprocessing,\n useMinio: state.shouldUseMinio ?? false,\n });\n state.generatedConfig = { ...config };\n await onProgress?.('New config generated');\n }\n\n private async doStepFetchPorts(state: PlatformaInitState) {\n state.step = 'fetchPorts';\n state.ports = await this.fetchPorts(state.remoteHome!, state.arch!);\n\n if (!state.ports.debug.remote\n || !state.ports.grpc.remote\n || !state.ports.minioPort.remote\n || !state.ports.minioConsolePort.remote\n || !state.ports.monitoring.remote\n || !state.ports.http?.remote) {\n throw new Error(`SshPl.platformaInit: remote ports are not defined`);\n }\n }\n\n private async doStepDownloadBinaries(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined, ops: SshPlConfig) {\n state.step = 'downloadBinaries';\n await onProgress?.('Downloading and uploading required binaries...');\n\n const glibcVersion = await getGlibcVersion(this.logger, this.sshClient);\n if (glibcVersion < minRequiredGlibcVersion)\n throw new Error(`glibc version ${glibcVersion} is too old. Version ${minRequiredGlibcVersion} or higher is required for Platforma.`);\n\n const downloadRes = await this.downloadBinariesAndUploadToTheServer(\n ops.localWorkdir, ops.plBinary!, state.remoteHome!, state.arch!, state.shouldUseMinio ?? false,\n );\n await onProgress?.('All required binaries have been downloaded and uploaded.');\n\n state.binPaths = { ...downloadRes, history: undefined };\n state.downloadedBinaries = downloadRes.history;\n }\n\n private async doStepDetectArch(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'detectArch';\n await onProgress?.('Detecting server architecture...');\n state.arch = await this.getArch();\n await onProgress?.('Server architecture detected.');\n }\n\n private async doStepDetectHome(state: PlatformaInitState, onProgress: ((...args: any) => Promise<any>) | undefined) {\n state.step = 'detectHome';\n await onProgress?.('Fetching user home directory...');\n state.remoteHome = await this.getUserHomeDirectory();\n await onProgress?.('User home directory retrieved.');\n }\n\n private async doStepReadExistedConfig(\n state: PlatformaInitState,\n ops: SshPlConfig,\n onProgress: ((...args: any) => Promise<any>) | undefined,\n ): Promise<boolean> {\n state.step = 'checkAlive';\n await onProgress?.('Checking platform status...');\n state.alive = await this.isAlive();\n\n if (!state.alive?.platforma) {\n return true;\n }\n\n await onProgress?.('All required services are running.');\n\n state.existedSettings = await this.readExistedConfig(state.remoteHome!);\n if (!state.existedSettings) {\n throw new Error(`SshPl.platformaInit: platforma is alive but existed settings are not found`);\n }\n\n const sameGA = state.existedSettings.useGlobalAccess == ops.useGlobalAccess;\n const samePlVersion = state.existedSettings.plVersion == ops.plBinary!.version;\n state.needRestart = !(sameGA && samePlVersion);\n this.logger.info(`SshPl.platformaInit: need restart? ${state.needRestart}`);\n\n state.shouldUseMinio = state.existedSettings.minioIsUsed;\n if (state.shouldUseMinio) {\n this.logger.info(`SshPl.platformaInit: minio is used`);\n } else {\n this.logger.info(`SshPl.platformaInit: minio is not used`);\n }\n\n if (!state.needRestart) {\n await onProgress?.('Server setup completed.');\n return false;\n }\n\n await onProgress?.('Stopping services...');\n await this.stop();\n\n return true;\n }\n\n public async downloadBinariesAndUploadToTheServer(\n localWorkdir: string,\n plBinary: PlBinarySourceDownload,\n remoteHome: string,\n arch: Arch,\n shouldUseMinio: boolean,\n ) {\n const state: DownloadAndUntarState[] = [];\n try {\n const pl = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'pl', `pl-${plBinary.version}`,\n );\n state.push(pl);\n\n const supervisor = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'supervisord', plpath.supervisordDirName,\n );\n state.push(supervisor);\n\n const minioPath = plpath.minioBin(remoteHome, arch.arch);\n if (shouldUseMinio) {\n const minio = await this.downloadAndUntar(\n localWorkdir, remoteHome, arch,\n 'minio', plpath.minioDirName,\n );\n state.push(minio);\n await this.sshClient.chmod(minioPath, 0o750);\n }\n\n return {\n history: state,\n minioRelPath: shouldUseMinio ? minioPath : undefined,\n downloadedPl: plpath.platformaBin(remoteHome, arch.arch),\n };\n } catch (e: unknown) {\n const msg = `SshPl.downloadBinariesAndUploadToServer: ${e}, state: ${JSON.stringify(state)}`;\n this.logger.error(msg);\n throw e;\n }\n }\n\n /** We have to extract pl in the remote server,\n * because Windows doesn't support symlinks\n * that are found in Linux pl binaries tgz archive.\n * For this reason, we extract all to the remote server.\n * It requires `tar` to be installed on the server\n * (it's not installed for Rocky Linux for example). */\n public async downloadAndUntar(\n localWorkdir: string,\n remoteHome: string,\n arch: Arch,\n softwareName: string,\n tgzName: string,\n ): Promise<DownloadAndUntarState> {\n const state: DownloadAndUntarState = {};\n state.binBasePath = plpath.binariesDir(remoteHome);\n await this.sshClient.ensureRemoteDirCreated(state.binBasePath);\n state.binBasePathCreated = true;\n\n let downloadBinaryResult: DownloadBinaryResult | null = null;\n const attempts = 5;\n for (let i = 1; i <= attempts; i++) {\n try {\n downloadBinaryResult = await downloadBinaryNoExtract({\n logger: this.logger,\n baseDir: localWorkdir,\n softwareName,\n tgzName,\n arch: arch.arch,\n platform: arch.platform,\n });\n break;\n } catch (e: unknown) {\n await sleep(300);\n if (i == attempts) {\n throw new Error(`downloadAndUntar: ${attempts} attempts, last error: ${e}`);\n }\n }\n }\n state.downloadResult = notEmpty(downloadBinaryResult);\n\n state.localArchivePath = upath.resolve(state.downloadResult.archivePath);\n state.remoteDir = upath.join(state.binBasePath, state.downloadResult.baseName);\n state.remoteArchivePath = state.remoteDir + '.tgz';\n\n await this.sshClient.ensureRemoteDirCreated(state.remoteDir);\n await this.sshClient.uploadFile(state.localArchivePath, state.remoteArchivePath);\n state.uploadDone = true;\n\n try {\n await this.sshClient.exec('hash tar');\n } catch (_) {\n throw new Error(`tar is not installed on the server. Please install it before running Platforma.`);\n }\n\n // TODO: Create a proper archive to avoid xattr warnings\n const untarResult = await this.sshClient.exec(\n `tar --warning=no-all -xvf ${state.remoteArchivePath} --directory=${state.remoteDir}`,\n );\n\n if (untarResult.stderr)\n throw new Error(`downloadAndUntar: untar: stderr occurred: ${untarResult.stderr}, stdout: ${untarResult.stdout}`);\n\n state.untarDone = true;\n\n return state;\n }\n\n public async needDownload(remoteHome: string, arch: Arch) {\n const checkPathSupervisor = plpath.supervisorBin(remoteHome, arch.arch);\n const checkPathMinio = plpath.minioDir(remoteHome, arch.arch);\n const checkPathPlatforma = plpath.platformaBin(remoteHome, arch.arch);\n\n if (!await this.sshClient.checkFileExists(checkPathPlatforma)\n || !await this.sshClient.checkFileExists(checkPathMinio)\n || !await this.sshClient.checkFileExists(checkPathSupervisor)) {\n return true;\n }\n\n return false;\n }\n\n public async checkIsAliveWithInterval(shouldUseMinio: boolean, interval: number = 1000, count = 15, shouldStart = true): Promise<void> {\n const maxMs = count * interval;\n\n let total = 0;\n let alive = await this.isAlive();\n while (shouldStart ? !isAllAlive(alive, shouldUseMinio) : isAllAlive(alive, shouldUseMinio)) {\n await sleep(interval);\n total += interval;\n if (total > maxMs) {\n throw new Error(`isAliveWithInterval: The process did not ${shouldStart ? 'started' : 'stopped'} after ${maxMs} ms. Live status: ${JSON.stringify(alive)}`);\n }\n alive = await this.isAlive();\n }\n }\n\n public async readExistedConfig(remoteHome: string): Promise<ConnectionInfo> {\n const connectionInfo = await this.sshClient.readFile(plpath.connectionInfo(remoteHome));\n return parseConnectionInfo(connectionInfo);\n }\n\n public async fetchPorts(remoteHome: string, arch: Arch): Promise<SshPlPorts> {\n const ports: SshPlPorts = {\n grpc: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n monitoring: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n debug: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n http: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n minioPort: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n minioConsolePort: {\n local: await getFreePort(),\n remote: await this.getFreePortForPlatformaOnServer(remoteHome, arch),\n },\n };\n\n return ports;\n }\n\n public async getLocalFreePort(): Promise<number> {\n return new Promise((res) => {\n const srv = net.createServer();\n srv.listen(0, () => {\n const port = (srv.address() as net.AddressInfo).port;\n srv.close((_) => res(port));\n });\n });\n }\n\n public async getFreePortForPlatformaOnServer(remoteHome: string, arch: Arch): Promise<number> {\n const freePortBin = plpath.platformaFreePortBin(remoteHome, arch.arch);\n\n const { stdout, stderr } = await this.sshClient.exec(`${freePortBin}`);\n if (stderr) {\n throw new Error(`getFreePortForPlatformaOnServer: stderr is not empty: ${stderr}, stdout: ${stdout}`);\n }\n\n return +stdout;\n }\n\n public async getArch(): Promise<Arch> {\n const { stdout, stderr } = await this.sshClient.exec('uname -s && uname -m');\n if (stderr)\n throw new Error(`getArch: stderr is not empty: ${stderr}, stdout: ${stdout}`);\n\n const arr = stdout.split('\\n');\n\n return {\n platform: arr[0],\n arch: arr[1],\n };\n }\n\n public async getUserHomeDirectory() {\n const { stdout, stderr } = await this.sshClient.exec('echo $HOME');\n\n if (stderr) {\n const home = `/home/${this.username}`;\n console.warn(`getUserHomeDirectory: stderr is not empty: ${stderr}, stdout: ${stdout}, will get a default home: ${home}`);\n\n return home;\n }\n\n return stdout.trim();\n }\n}\n\ntype Arch = { platform: string; arch: string };\n\nexport type SshPlConfig = {\n localWorkdir: string;\n license: PlLicenseMode;\n useGlobalAccess?: boolean;\n plBinary?: PlBinarySourceDownload;\n\n onProgress?: (...args: any) => Promise<any>;\n plConfigPostprocessing?: (config: PlConfig) => PlConfig;\n};\n\nconst defaultSshPlConfig: Pick<\n SshPlConfig,\n | 'useGlobalAccess'\n | 'plBinary'\n> = {\n useGlobalAccess: false,\n plBinary: {\n type: 'Download',\n version: getDefaultPlVersion(),\n },\n};\n\ntype BinPaths = {\n history?: DownloadAndUntarState[];\n minioRelPath?: string;\n downloadedPl: string;\n};\n\ntype DownloadAndUntarState = {\n binBasePath?: string;\n binBasePathCreated?: boolean;\n downloadResult?: DownloadBinaryResult;\n attempts?: number;\n\n localArchivePath?: string;\n remoteDir?: string;\n remoteArchivePath?: string;\n uploadDone?: boolean;\n untarDone?: boolean;\n};\n\ntype PlatformaInitStep =\n 'init'\n | 'detectArch'\n | 'detectHome'\n | 'checkAlive'\n | 'stopExistedPlatforma'\n | 'downloadBinaries'\n | 'fetchPorts'\n | 'generateNewConfig'\n | 'createFoldersAndSaveFiles'\n | 'configureSupervisord'\n | 'saveNewConnectionInfo'\n | 'startPlatforma';\n\ntype PlatformaInitState = {\n step: PlatformaInitStep;\n localWorkdir?: string;\n plBinaryOps?: PlBinarySourceDownload;\n arch?: Arch;\n remoteHome?: string;\n alive?: SupervisorStatus;\n existedSettings?: ConnectionInfo;\n needRestart?: boolean;\n shouldUseMinio?: boolean;\n downloadedBinaries?: DownloadAndUntarState[];\n binPaths?: BinPaths;\n ports?: SshPlPorts;\n generatedConfig?: SshPlConfigGenerationResult;\n connectionInfo?: ConnectionInfo;\n started?: boolean;\n};\n\n/**\n * Gets the glibc version on the remote system\n * @returns The glibc version as a number\n * @throws Error if version cannot be determined\n */\nasync function getGlibcVersion(logger: MiLogger, sshClient: SshClient): Promise <number> {\n try {\n const { stdout, stderr } = await sshClient.exec('ldd --version | head -n 1');\n if (stderr) {\n throw new Error(`Failed to check glibc version: ${stderr}`);\n }\n return parseGlibcVersion(stdout);\n } catch (e: unknown) {\n logger.error(`glibc version check failed: ${e}`);\n throw e;\n }\n}\n\nexport function parseGlibcVersion(output: string): number {\n const versionMatch = output.match(/\\d+\\.\\d+/);\n if (!versionMatch) {\n throw new Error(`Could not parse glibc version from: ${output}`);\n }\n\n return parseFloat(versionMatch[0]);\n}\n"],"names":["SshClient","notEmpty","supervisorStatus","isAllAlive","supervisorCtlStart","plpath.platformaCliLogs","isSupervisordRunning","supervisorCtlShutdown","plpath.workDir","newConnectionInfo","plpath.connectionInfo","stringifyConnectionInfo","generateSupervisordConfigWithMinio","generateSupervisordConfig","plpath.supervisorConf","generateSshPlConfigs","plpath.supervisordDirName","plpath.minioBin","plpath.minioDirName","plpath.platformaBin","plpath.binariesDir","downloadBinaryNoExtract","sleep","plpath.supervisorBin","plpath.minioDir","parseConnectionInfo","getFreePort","plpath.platformaFreePortBin","getDefaultPlVersion"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,uBAAuB,GAAG,IAAI;MAEvB,KAAK,CAAA;AAGE,IAAA,MAAA;AACA,IAAA,SAAA;AACC,IAAA,QAAA;AAJX,IAAA,SAAS,GAAuB,EAAE,IAAI,EAAE,MAAM,EAAE;AACxD,IAAA,WAAA,CACkB,MAAgB,EAChB,SAAoB,EACnB,QAAgB,EAAA;QAFjB,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,SAAS,GAAT,SAAS;QACR,IAAA,CAAA,QAAQ,GAAR,QAAQ;IACvB;IAEG,IAAI,GAAA;QACT,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B;IACH;AAEO,IAAA,aAAa,IAAI,CAAC,MAAgB,EAAE,MAAyB,EAAA;AAClE,QAAA,IAAI;YACF,MAAM,SAAS,GAAG,MAAMA,aAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;AACtD,YAAA,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,EAAEC,kBAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAChE;QAAE,OAAO,CAAU,EAAE;AACnB,YAAA,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAA,CAAE,CAAC;AACxD,YAAA,MAAM,CAAC;QACT;IACF;IAEO,OAAO,GAAA;AACZ,QAAA,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;IACxB;;AAGO,IAAA,MAAM,OAAO,GAAA;AAClB,QAAA,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;AACjC,QAAA,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,EAAE;AACpD,QAAA,OAAO,MAAMC,4BAAgB,CAAC,IAAI,CAA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CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,KAAK,iBAAiB,GACpB,MAAM,GACJ,YAAY,GACZ,YAAY,GACZ,YAAY,GACZ,sBAAsB,GACtB,kBAAkB,GAClB,YAAY,GACZ,mBAAmB,GACnB,2BAA2B,GAC3B,sBAAsB,GACtB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,iBAAiB,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,eAAe,CAAC,EAAE,2BAA2B,CAAC;IAC9C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAoBF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOxD"}
|
package/dist/ssh/pl.js
CHANGED
|
@@ -336,7 +336,14 @@ class SshPl {
|
|
|
336
336
|
const attempts = 5;
|
|
337
337
|
for (let i = 1; i <= attempts; i++) {
|
|
338
338
|
try {
|
|
339
|
-
downloadBinaryResult = await downloadBinaryNoExtract(
|
|
339
|
+
downloadBinaryResult = await downloadBinaryNoExtract({
|
|
340
|
+
logger: this.logger,
|
|
341
|
+
baseDir: localWorkdir,
|
|
342
|
+
softwareName,
|
|
343
|
+
tgzName,
|
|
344
|
+
arch: arch.arch,
|
|
345
|
+
platform: arch.platform,
|
|
346
|
+
});
|
|
340
347
|
break;
|
|
341
348
|
}
|
|
342
349
|
catch (e) {
|