@milaboratories/pl-deployments 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +542 -539
- package/dist/index.mjs.map +1 -1
- package/dist/ssh/pl.d.ts +1 -0
- package/dist/ssh/pl.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/ssh/pl.ts +39 -4
package/src/ssh/pl.ts
CHANGED
|
@@ -117,6 +117,8 @@ export class SshPl {
|
|
|
117
117
|
public async platformaInit(options: SshPlConfig): Promise<ConnectionInfo> {
|
|
118
118
|
const state: PlatformaInitState = { localWorkdir: options.localWorkdir };
|
|
119
119
|
|
|
120
|
+
const { onProgress } = options;
|
|
121
|
+
|
|
120
122
|
try {
|
|
121
123
|
// merge options with default ops.
|
|
122
124
|
const ops: SshPlConfig = {
|
|
@@ -124,11 +126,22 @@ export class SshPl {
|
|
|
124
126
|
...options,
|
|
125
127
|
};
|
|
126
128
|
state.plBinaryOps = ops.plBinary;
|
|
129
|
+
|
|
130
|
+
await onProgress?.('Detecting server architecture...');
|
|
127
131
|
state.arch = await this.getArch();
|
|
132
|
+
await onProgress?.('Server architecture detected.');
|
|
133
|
+
|
|
134
|
+
await onProgress?.('Fetching user home directory...');
|
|
128
135
|
state.remoteHome = await this.getUserHomeDirectory();
|
|
136
|
+
await onProgress?.('User home directory retrieved.');
|
|
129
137
|
|
|
138
|
+
await onProgress?.('Checking platform status...');
|
|
130
139
|
state.alive = await this.isAlive();
|
|
131
140
|
|
|
141
|
+
if (state.alive.allAlive) {
|
|
142
|
+
await onProgress?.('All required services are running.');
|
|
143
|
+
}
|
|
144
|
+
|
|
132
145
|
if (state.alive.allAlive) {
|
|
133
146
|
state.userCredentials = await this.getUserCredentials(state.remoteHome);
|
|
134
147
|
if (!state.userCredentials) {
|
|
@@ -139,12 +152,17 @@ export class SshPl {
|
|
|
139
152
|
state.needRestart = !(sameGA && samePlVersion);
|
|
140
153
|
this.logger.info(`SshPl.platformaInit: need restart? ${state.needRestart}`);
|
|
141
154
|
|
|
142
|
-
if (!state.needRestart)
|
|
155
|
+
if (!state.needRestart) {
|
|
156
|
+
await onProgress?.('Server setup completed.');
|
|
143
157
|
return state.userCredentials;
|
|
158
|
+
}
|
|
144
159
|
|
|
160
|
+
await onProgress?.('Stopping services...');
|
|
145
161
|
await this.stop();
|
|
146
162
|
}
|
|
147
163
|
|
|
164
|
+
await onProgress?.('Downloading and uploading required binaries...');
|
|
165
|
+
|
|
148
166
|
const glibcVersion = await getGlibcVersion(this.logger, this.sshClient);
|
|
149
167
|
if (glibcVersion < minRequiredGlibcVersion)
|
|
150
168
|
throw new Error(`glibc version ${glibcVersion} is too old. Version ${minRequiredGlibcVersion} or higher is required for Platforma.`);
|
|
@@ -152,6 +170,8 @@ export class SshPl {
|
|
|
152
170
|
const downloadRes = await this.downloadBinariesAndUploadToTheServer(
|
|
153
171
|
ops.localWorkdir, ops.plBinary!, state.remoteHome, state.arch,
|
|
154
172
|
);
|
|
173
|
+
await onProgress?.('All required binaries have been downloaded and uploaded.');
|
|
174
|
+
|
|
155
175
|
state.binPaths = { ...downloadRes, history: undefined };
|
|
156
176
|
state.downloadedBinaries = downloadRes.history;
|
|
157
177
|
|
|
@@ -161,6 +181,7 @@ export class SshPl {
|
|
|
161
181
|
throw new Error(`SshPl.platformaInit: remote ports are not defined`);
|
|
162
182
|
}
|
|
163
183
|
|
|
184
|
+
await onProgress?.('Generating server configuration...');
|
|
164
185
|
const config = await generateSshPlConfigs({
|
|
165
186
|
logger: this.logger,
|
|
166
187
|
workingDir: plpath.workDir(state.remoteHome),
|
|
@@ -183,6 +204,9 @@ export class SshPl {
|
|
|
183
204
|
});
|
|
184
205
|
state.generatedConfig = { ...config, filesToCreate: { skipped: 'it is too wordy' } };
|
|
185
206
|
|
|
207
|
+
await onProgress?.('Server configuration generated.');
|
|
208
|
+
|
|
209
|
+
await onProgress?.('Generating folder structure...');
|
|
186
210
|
for (const [filePath, content] of Object.entries(config.filesToCreate)) {
|
|
187
211
|
await this.sshClient.writeFileOnTheServer(filePath, content);
|
|
188
212
|
this.logger.info(`Created file ${filePath}`);
|
|
@@ -192,7 +216,9 @@ export class SshPl {
|
|
|
192
216
|
await this.sshClient.ensureRemoteDirCreated(dir);
|
|
193
217
|
this.logger.info(`Created directory ${dir}`);
|
|
194
218
|
}
|
|
219
|
+
await onProgress?.('Folder structure created.');
|
|
195
220
|
|
|
221
|
+
await onProgress?.('Writing supervisord configuration...');
|
|
196
222
|
const supervisorConfig = generateSupervisordConfig(
|
|
197
223
|
config.minioConfig.storageDir,
|
|
198
224
|
config.minioConfig.envs,
|
|
@@ -207,7 +233,9 @@ export class SshPl {
|
|
|
207
233
|
if (!writeResult) {
|
|
208
234
|
throw new Error(`Can not write supervisord config on the server ${plpath.workDir(state.remoteHome)}`);
|
|
209
235
|
}
|
|
236
|
+
await onProgress?.('Supervisord configuration written.');
|
|
210
237
|
|
|
238
|
+
await onProgress?.('Saving connection information...');
|
|
211
239
|
state.connectionInfo = newConnectionInfo(
|
|
212
240
|
config.plUser,
|
|
213
241
|
config.plPassword,
|
|
@@ -219,11 +247,15 @@ export class SshPl {
|
|
|
219
247
|
plpath.connectionInfo(state.remoteHome),
|
|
220
248
|
stringifyConnectionInfo(state.connectionInfo),
|
|
221
249
|
);
|
|
250
|
+
await onProgress?.('Connection information saved.');
|
|
222
251
|
|
|
252
|
+
await onProgress?.('Starting Platforma on the server...');
|
|
223
253
|
await this.start();
|
|
224
254
|
state.started = true;
|
|
225
255
|
this.initState = state;
|
|
226
256
|
|
|
257
|
+
await onProgress?.('Platforma has been started successfully.');
|
|
258
|
+
|
|
227
259
|
return state.connectionInfo;
|
|
228
260
|
} catch (e: unknown) {
|
|
229
261
|
const msg = `SshPl.platformaInit: ${e}, state: ${JSON.stringify(state)}`;
|
|
@@ -455,6 +487,9 @@ export type SshPlConfig = {
|
|
|
455
487
|
license: PlLicenseMode;
|
|
456
488
|
useGlobalAccess?: boolean;
|
|
457
489
|
plBinary?: PlBinarySourceDownload;
|
|
490
|
+
|
|
491
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
492
|
+
onProgress?: (...args: any) => Promise<any>;
|
|
458
493
|
plConfigPostprocessing?: (config: PlConfig) => PlConfig;
|
|
459
494
|
};
|
|
460
495
|
|
|
@@ -513,11 +548,11 @@ type PlatformaInitState = {
|
|
|
513
548
|
async function getGlibcVersion(logger: MiLogger, sshClient: SshClient): Promise <number> {
|
|
514
549
|
try {
|
|
515
550
|
const { stdout, stderr } = await sshClient.exec('ldd --version | head -n 1');
|
|
516
|
-
if(stderr) {
|
|
551
|
+
if (stderr) {
|
|
517
552
|
throw new Error(`Failed to check glibc version: ${stderr}`);
|
|
518
553
|
}
|
|
519
|
-
|
|
520
|
-
} catch(e: unknown) {
|
|
554
|
+
return parseGlibcVersion(stdout);
|
|
555
|
+
} catch (e: unknown) {
|
|
521
556
|
logger.error(`glibc version check failed: ${e}`);
|
|
522
557
|
throw e;
|
|
523
558
|
}
|