@platforma-sdk/bootstrap 5.2.40 → 5.2.42
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/README.md +10 -2
- package/assets/compose-backend.yaml +2 -2
- package/bin/run.js +3 -3
- package/dist/block.cjs +36 -31
- package/dist/block.cjs.map +1 -1
- package/dist/block.d.ts +2 -2
- package/dist/block.d.ts.map +1 -1
- package/dist/block.js +36 -31
- package/dist/block.js.map +1 -1
- package/dist/cmd-opts.cjs +74 -74
- package/dist/cmd-opts.cjs.map +1 -1
- package/dist/cmd-opts.d.ts +23 -23
- package/dist/cmd-opts.d.ts.map +1 -1
- package/dist/cmd-opts.js +74 -74
- package/dist/cmd-opts.js.map +1 -1
- package/dist/commands/create-block.cjs +3 -3
- package/dist/commands/create-block.cjs.map +1 -1
- package/dist/commands/create-block.d.ts +2 -2
- package/dist/commands/create-block.d.ts.map +1 -1
- package/dist/commands/create-block.js +3 -3
- package/dist/commands/create-block.js.map +1 -1
- package/dist/commands/reset.cjs +3 -3
- package/dist/commands/reset.cjs.map +1 -1
- package/dist/commands/reset.d.ts +2 -2
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +3 -3
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/start/docker/s3.cjs +18 -18
- package/dist/commands/start/docker/s3.cjs.map +1 -1
- package/dist/commands/start/docker/s3.d.ts +15 -15
- package/dist/commands/start/docker/s3.d.ts.map +1 -1
- package/dist/commands/start/docker/s3.js +18 -18
- package/dist/commands/start/docker/s3.js.map +1 -1
- package/dist/commands/start/docker.cjs +18 -18
- package/dist/commands/start/docker.cjs.map +1 -1
- package/dist/commands/start/docker.d.ts +16 -16
- package/dist/commands/start/docker.d.ts.map +1 -1
- package/dist/commands/start/docker.js +18 -18
- package/dist/commands/start/docker.js.map +1 -1
- package/dist/commands/start/local/s3.cjs +36 -34
- package/dist/commands/start/local/s3.cjs.map +1 -1
- package/dist/commands/start/local/s3.d.ts +18 -18
- package/dist/commands/start/local/s3.d.ts.map +1 -1
- package/dist/commands/start/local/s3.js +36 -34
- package/dist/commands/start/local/s3.js.map +1 -1
- package/dist/commands/start/local.cjs +32 -30
- package/dist/commands/start/local.cjs.map +1 -1
- package/dist/commands/start/local.d.ts +16 -16
- package/dist/commands/start/local.d.ts.map +1 -1
- package/dist/commands/start/local.js +32 -30
- package/dist/commands/start/local.js.map +1 -1
- package/dist/commands/start.cjs +3 -3
- package/dist/commands/start.cjs.map +1 -1
- package/dist/commands/start.d.ts +2 -2
- package/dist/commands/start.js +3 -3
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.cjs +4 -4
- package/dist/commands/stop.cjs.map +1 -1
- package/dist/commands/stop.d.ts +2 -2
- package/dist/commands/stop.js +4 -4
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/svc/create/arg-parser.cjs +13 -13
- package/dist/commands/svc/create/arg-parser.cjs.map +1 -1
- package/dist/commands/svc/create/arg-parser.d.ts +1 -1
- package/dist/commands/svc/create/arg-parser.js +13 -13
- package/dist/commands/svc/create/arg-parser.js.map +1 -1
- package/dist/commands/svc/create/docker/s3.cjs +27 -27
- package/dist/commands/svc/create/docker/s3.cjs.map +1 -1
- package/dist/commands/svc/create/docker/s3.d.ts +15 -15
- package/dist/commands/svc/create/docker/s3.d.ts.map +1 -1
- package/dist/commands/svc/create/docker/s3.js +27 -27
- package/dist/commands/svc/create/docker/s3.js.map +1 -1
- package/dist/commands/svc/create/docker.cjs +35 -35
- package/dist/commands/svc/create/docker.cjs.map +1 -1
- package/dist/commands/svc/create/docker.d.ts +16 -16
- package/dist/commands/svc/create/docker.js +35 -35
- package/dist/commands/svc/create/docker.js.map +1 -1
- package/dist/commands/svc/create/local/s3.cjs +37 -35
- package/dist/commands/svc/create/local/s3.cjs.map +1 -1
- package/dist/commands/svc/create/local/s3.d.ts +18 -18
- package/dist/commands/svc/create/local/s3.d.ts.map +1 -1
- package/dist/commands/svc/create/local/s3.js +37 -35
- package/dist/commands/svc/create/local/s3.js.map +1 -1
- package/dist/commands/svc/create/local.cjs +35 -35
- package/dist/commands/svc/create/local.cjs.map +1 -1
- package/dist/commands/svc/create/local.d.ts +16 -16
- package/dist/commands/svc/create/local.d.ts.map +1 -1
- package/dist/commands/svc/create/local.js +35 -35
- package/dist/commands/svc/create/local.js.map +1 -1
- package/dist/commands/svc/delete.cjs +4 -4
- package/dist/commands/svc/delete.cjs.map +1 -1
- package/dist/commands/svc/delete.d.ts +2 -2
- package/dist/commands/svc/delete.js +4 -4
- package/dist/commands/svc/delete.js.map +1 -1
- package/dist/commands/svc/down.cjs +3 -3
- package/dist/commands/svc/down.cjs.map +1 -1
- package/dist/commands/svc/down.d.ts +2 -2
- package/dist/commands/svc/down.js +3 -3
- package/dist/commands/svc/down.js.map +1 -1
- package/dist/commands/svc/list.cjs +5 -5
- package/dist/commands/svc/list.cjs.map +1 -1
- package/dist/commands/svc/list.d.ts +1 -1
- package/dist/commands/svc/list.d.ts.map +1 -1
- package/dist/commands/svc/list.js +5 -5
- package/dist/commands/svc/list.js.map +1 -1
- package/dist/commands/svc/up.cjs +5 -5
- package/dist/commands/svc/up.cjs.map +1 -1
- package/dist/commands/svc/up.d.ts +2 -2
- package/dist/commands/svc/up.d.ts.map +1 -1
- package/dist/commands/svc/up.js +5 -5
- package/dist/commands/svc/up.js.map +1 -1
- package/dist/core.cjs +261 -231
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +10 -10
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +261 -231
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +29 -29
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/package.cjs +2 -2
- package/dist/package.cjs.map +1 -1
- package/dist/package.js +2 -2
- package/dist/package.js.map +1 -1
- package/dist/platforma.cjs +24 -24
- package/dist/platforma.cjs.map +1 -1
- package/dist/platforma.d.ts +1 -1
- package/dist/platforma.d.ts.map +1 -1
- package/dist/platforma.js +24 -24
- package/dist/platforma.js.map +1 -1
- package/dist/run.cjs +6 -6
- package/dist/run.cjs.map +1 -1
- package/dist/run.d.ts +3 -3
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +6 -6
- package/dist/run.js.map +1 -1
- package/dist/state.cjs +16 -14
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.ts +5 -5
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +16 -14
- package/dist/state.js.map +1 -1
- package/dist/templates/compose.cjs +2 -2
- package/dist/templates/compose.cjs.map +1 -1
- package/dist/templates/compose.d.ts.map +1 -1
- package/dist/templates/compose.js +2 -2
- package/dist/templates/compose.js.map +1 -1
- package/dist/templates/pl-config.cjs +49 -49
- package/dist/templates/pl-config.cjs.map +1 -1
- package/dist/templates/pl-config.d.ts +2 -2
- package/dist/templates/pl-config.d.ts.map +1 -1
- package/dist/templates/pl-config.js +49 -49
- package/dist/templates/pl-config.js.map +1 -1
- package/dist/templates/types.cjs +12 -12
- package/dist/templates/types.cjs.map +1 -1
- package/dist/templates/types.d.ts +6 -6
- package/dist/templates/types.d.ts.map +1 -1
- package/dist/templates/types.js +12 -12
- package/dist/templates/types.js.map +1 -1
- package/dist/util.cjs +19 -17
- package/dist/util.cjs.map +1 -1
- package/dist/util.d.ts +2 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +19 -17
- package/dist/util.js.map +1 -1
- package/package.json +23 -22
package/dist/core.js
CHANGED
|
@@ -17,8 +17,8 @@ class Core {
|
|
|
17
17
|
startLast() {
|
|
18
18
|
const instance = state.currentInstance;
|
|
19
19
|
if (!instance) {
|
|
20
|
-
this.logger.error(
|
|
21
|
-
throw new Error(
|
|
20
|
+
this.logger.error("failed to bring back Platforma Backend in the last started configuration: no last configuration found");
|
|
21
|
+
throw new Error("no previous run info found");
|
|
22
22
|
}
|
|
23
23
|
return this.startInstance(instance);
|
|
24
24
|
}
|
|
@@ -29,7 +29,7 @@ class Core {
|
|
|
29
29
|
}
|
|
30
30
|
const result = runCommands(this.logger, instance.upCommands);
|
|
31
31
|
checkRunError(result.executed);
|
|
32
|
-
if (result.spawned.length > 0 && instance.type ===
|
|
32
|
+
if (result.spawned.length > 0 && instance.type === "process") {
|
|
33
33
|
instance.pid = result.spawned[result.spawned.length - 1].pid;
|
|
34
34
|
state.setInstanceInfo(instance.name, instance);
|
|
35
35
|
this.logger.info(`instance '${instance.name}' started`);
|
|
@@ -43,10 +43,10 @@ class Core {
|
|
|
43
43
|
checkRunError(result.executed);
|
|
44
44
|
const iType = instance.type;
|
|
45
45
|
switch (iType) {
|
|
46
|
-
case
|
|
46
|
+
case "docker": {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
case
|
|
49
|
+
case "process": {
|
|
50
50
|
if (instance.pid && state.isInstanceActive(instance)) {
|
|
51
51
|
process.kill(instance.pid);
|
|
52
52
|
}
|
|
@@ -69,9 +69,9 @@ class Core {
|
|
|
69
69
|
return this.startInstance(instance);
|
|
70
70
|
}
|
|
71
71
|
createLocal(instanceName, options) {
|
|
72
|
-
let plBinaryPath = binaryPath(options?.version,
|
|
72
|
+
let plBinaryPath = binaryPath(options?.version, "binaries", "platforma");
|
|
73
73
|
if (options?.sourcesPath) {
|
|
74
|
-
plBinaryPath = path.join(os__default.tmpdir(),
|
|
74
|
+
plBinaryPath = path.join(os__default.tmpdir(), "platforma-custom-build");
|
|
75
75
|
}
|
|
76
76
|
if (options?.binaryPath) {
|
|
77
77
|
plBinaryPath = options.binaryPath;
|
|
@@ -104,17 +104,17 @@ class Core {
|
|
|
104
104
|
`${configOptions.localRoot}/packages-local`,
|
|
105
105
|
`${configOptions.localRoot}/blocks-local`,
|
|
106
106
|
];
|
|
107
|
-
if (configOptions.storages.primary.type ===
|
|
107
|
+
if (configOptions.storages.primary.type === "FS") {
|
|
108
108
|
storageDirs.push(configOptions.storages.primary.rootPath);
|
|
109
109
|
}
|
|
110
|
-
if (configOptions.storages.library.type ===
|
|
110
|
+
if (configOptions.storages.library.type === "FS") {
|
|
111
111
|
storageDirs.push(configOptions.storages.library.rootPath);
|
|
112
112
|
configOptions.hacks.libraryDownloadable = false;
|
|
113
113
|
}
|
|
114
|
-
if (configOptions.storages.work.type ===
|
|
114
|
+
if (configOptions.storages.work.type === "FS") {
|
|
115
115
|
storageDirs.push(configOptions.storages.work.rootPath);
|
|
116
116
|
}
|
|
117
|
-
this.logger.debug(
|
|
117
|
+
this.logger.debug(" creating pl state directories...");
|
|
118
118
|
for (const dir of storageDirs) {
|
|
119
119
|
if (!fs__default.existsSync(dir)) {
|
|
120
120
|
this.logger.debug(` '${dir}'`);
|
|
@@ -122,36 +122,36 @@ class Core {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
for (const drv of configOptions.core.auth.drivers) {
|
|
125
|
-
if (drv.driver ===
|
|
125
|
+
if (drv.driver === "htpasswd") {
|
|
126
126
|
if (!fs__default.existsSync(drv.path)) {
|
|
127
127
|
this.logger.debug(` installing default 'users.htpasswd' to ${drv.path}...`);
|
|
128
|
-
fs__default.copyFileSync(assets(
|
|
128
|
+
fs__default.copyFileSync(assets("users.htpasswd"), drv.path);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
if (!configPath) {
|
|
133
|
-
configPath = path.join(configOptions.localRoot,
|
|
133
|
+
configPath = path.join(configOptions.localRoot, "config.yaml");
|
|
134
134
|
this.logger.debug(` rendering configuration '${configPath}'...`);
|
|
135
135
|
fs__default.writeFileSync(configPath, render(configOptions));
|
|
136
136
|
}
|
|
137
137
|
const upCommands = [];
|
|
138
138
|
if (options?.sourcesPath) {
|
|
139
139
|
upCommands.push({
|
|
140
|
-
cmd:
|
|
141
|
-
args: [
|
|
142
|
-
workdir: path.resolve(options.sourcesPath,
|
|
140
|
+
cmd: "go",
|
|
141
|
+
args: ["build", "-o", plBinaryPath, "."],
|
|
142
|
+
workdir: path.resolve(options.sourcesPath, "cmd", "platforma"),
|
|
143
143
|
runOpts: {
|
|
144
|
-
stdio:
|
|
144
|
+
stdio: "inherit",
|
|
145
145
|
},
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
const runBinary = {
|
|
149
149
|
async: true,
|
|
150
150
|
cmd: plBinaryPath,
|
|
151
|
-
args: [
|
|
151
|
+
args: ["--quiet", "--config", configPath],
|
|
152
152
|
workdir: workdir,
|
|
153
153
|
runOpts: {
|
|
154
|
-
stdio:
|
|
154
|
+
stdio: "inherit",
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
if (options?.configOptions?.numCpu) {
|
|
@@ -165,7 +165,7 @@ class Core {
|
|
|
165
165
|
runBinary.runOpts.env = {};
|
|
166
166
|
}
|
|
167
167
|
for (const cmd of options.backendCommands) {
|
|
168
|
-
const equalIndex = cmd.indexOf(
|
|
168
|
+
const equalIndex = cmd.indexOf("=");
|
|
169
169
|
if (equalIndex > 0) {
|
|
170
170
|
const key = cmd.substring(0, equalIndex);
|
|
171
171
|
const value = cmd.substring(equalIndex + 1);
|
|
@@ -178,13 +178,13 @@ class Core {
|
|
|
178
178
|
}
|
|
179
179
|
// Process additional backend commands
|
|
180
180
|
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
181
|
-
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(
|
|
181
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
|
|
182
182
|
// Add commands as arguments to the binary
|
|
183
183
|
runBinary.args = [...runBinary.args, ...options.backendCommands];
|
|
184
184
|
}
|
|
185
185
|
upCommands.push(runBinary);
|
|
186
186
|
state.setInstanceInfo(instanceName, {
|
|
187
|
-
type:
|
|
187
|
+
type: "process",
|
|
188
188
|
upCommands: upCommands,
|
|
189
189
|
downCommands: [],
|
|
190
190
|
cleanupCommands: [],
|
|
@@ -201,47 +201,38 @@ class Core {
|
|
|
201
201
|
return state.getInstanceInfo(instanceName);
|
|
202
202
|
}
|
|
203
203
|
createLocalS3(instanceName, options) {
|
|
204
|
-
this.logger.debug(
|
|
204
|
+
this.logger.debug("creating platforma instance in 'local s3' mode...");
|
|
205
205
|
const minioPort = options?.minioPort ?? 9000;
|
|
206
206
|
const instance = this.createLocal(instanceName, {
|
|
207
207
|
...options,
|
|
208
|
-
primaryURL: options?.primaryURL ??
|
|
209
|
-
|
|
208
|
+
primaryURL: options?.primaryURL ??
|
|
209
|
+
`s3e://testuser:testpassword@localhost:${minioPort}/platforma-primary-bucket/?region=no-region`,
|
|
210
|
+
libraryURL: options?.libraryURL ??
|
|
211
|
+
`s3e://testuser:testpassword@localhost:${minioPort}/platforma-library-bucket/?region=no-region`,
|
|
210
212
|
});
|
|
211
213
|
const localRoot = options?.configOptions?.localRoot;
|
|
212
214
|
const minioRunCmd = this.createMinio(instanceName, {
|
|
213
215
|
minioPort: minioPort,
|
|
214
216
|
minioConsolePort: options?.minioConsolePort,
|
|
215
|
-
storage: localRoot ? path.join(localRoot,
|
|
217
|
+
storage: localRoot ? path.join(localRoot, "minio") : undefined,
|
|
216
218
|
});
|
|
217
|
-
instance.upCommands = [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
];
|
|
221
|
-
instance.downCommands = [
|
|
222
|
-
minioRunCmd.stop,
|
|
223
|
-
...instance.downCommands,
|
|
224
|
-
];
|
|
225
|
-
instance.cleanupCommands = [
|
|
226
|
-
minioRunCmd.cleanup,
|
|
227
|
-
...instance.cleanupCommands,
|
|
228
|
-
];
|
|
219
|
+
instance.upCommands = [minioRunCmd.start, ...instance.upCommands];
|
|
220
|
+
instance.downCommands = [minioRunCmd.stop, ...instance.downCommands];
|
|
221
|
+
instance.cleanupCommands = [minioRunCmd.cleanup, ...instance.cleanupCommands];
|
|
229
222
|
state.setInstanceInfo(instanceName, instance);
|
|
230
223
|
return instance;
|
|
231
224
|
}
|
|
232
225
|
createMinio(instanceName, options) {
|
|
233
|
-
this.logger.debug(
|
|
234
|
-
const composeSrc = assets(
|
|
235
|
-
const composeMinio = state.instanceDir(instanceName,
|
|
236
|
-
render$1(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([
|
|
237
|
-
|
|
238
|
-
]), { dropVolumes: true });
|
|
239
|
-
const version = options?.version ? `:${options.version}` : '';
|
|
226
|
+
this.logger.debug(" creating docker compose for minio service...");
|
|
227
|
+
const composeSrc = assets("compose-backend.yaml");
|
|
228
|
+
const composeMinio = state.instanceDir(instanceName, "compose-minio.yaml");
|
|
229
|
+
render$1(composeSrc, composeMinio, `pl-${instanceName}-minio`, new Map([["minio", {}]]), { dropVolumes: true });
|
|
230
|
+
const version = options?.version ? `:${options.version}` : "";
|
|
240
231
|
this.logger.debug(` minio version: ${version}`);
|
|
241
232
|
const image = options?.image ?? `quay.io/minio/minio${version}`;
|
|
242
233
|
this.logger.debug(` minio image: ${image}`);
|
|
243
|
-
const storage = options?.storage ?? state.instanceDir(instanceName,
|
|
244
|
-
ensureDir(storage, { mode:
|
|
234
|
+
const storage = options?.storage ?? state.instanceDir(instanceName, "minio");
|
|
235
|
+
ensureDir(storage, { mode: "0775" });
|
|
245
236
|
const minioPort = options?.minioPort ?? 9000;
|
|
246
237
|
const minioConsolePort = options?.minioConsolePort ?? 9001;
|
|
247
238
|
const envs = {
|
|
@@ -252,67 +243,74 @@ class Core {
|
|
|
252
243
|
};
|
|
253
244
|
return {
|
|
254
245
|
start: {
|
|
255
|
-
cmd:
|
|
256
|
-
args: [
|
|
246
|
+
cmd: "docker",
|
|
247
|
+
args: [
|
|
248
|
+
"compose",
|
|
249
|
+
`--file=${composeMinio}`,
|
|
250
|
+
"up",
|
|
251
|
+
"--detach",
|
|
252
|
+
"--remove-orphans",
|
|
253
|
+
"--pull=missing",
|
|
254
|
+
],
|
|
257
255
|
envs: envs,
|
|
258
256
|
workdir: state.instanceDir(instanceName),
|
|
259
|
-
runOpts: { stdio:
|
|
257
|
+
runOpts: { stdio: "inherit" },
|
|
260
258
|
},
|
|
261
259
|
stop: {
|
|
262
|
-
cmd:
|
|
263
|
-
args: [
|
|
260
|
+
cmd: "docker",
|
|
261
|
+
args: ["compose", `--file=${composeMinio}`, "down"],
|
|
264
262
|
envs: envs,
|
|
265
263
|
workdir: state.instanceDir(instanceName),
|
|
266
|
-
runOpts: { stdio:
|
|
264
|
+
runOpts: { stdio: "inherit" },
|
|
267
265
|
},
|
|
268
266
|
cleanup: {
|
|
269
|
-
cmd:
|
|
270
|
-
args: [
|
|
267
|
+
cmd: "docker",
|
|
268
|
+
args: ["compose", `--file=${composeMinio}`, "down", "--volumes", "--remove-orphans"],
|
|
271
269
|
envs: envs,
|
|
272
270
|
workdir: state.instanceDir(instanceName),
|
|
273
|
-
runOpts: { stdio:
|
|
271
|
+
runOpts: { stdio: "inherit" },
|
|
274
272
|
},
|
|
275
273
|
};
|
|
276
274
|
}
|
|
277
275
|
createDockerS3(instanceName, localRoot, options) {
|
|
278
|
-
this.logger.debug(
|
|
279
|
-
const composeS3Path = assets(
|
|
276
|
+
this.logger.debug("creating platforma instance in 'docker s3' mode...");
|
|
277
|
+
const composeS3Path = assets("compose-backend.yaml");
|
|
280
278
|
const image = options?.image ?? plImageTag(options?.version);
|
|
281
279
|
this.checkLicense(options?.license, options?.licenseFile);
|
|
282
280
|
const storagePath = (...s) => path.join(localRoot, ...s);
|
|
283
281
|
const storageDir = (s) => {
|
|
284
282
|
const p = storagePath(s);
|
|
285
|
-
ensureDir(p, { mode:
|
|
283
|
+
ensureDir(p, { mode: "0775" });
|
|
286
284
|
return p;
|
|
287
285
|
};
|
|
288
|
-
const logFilePath = storagePath(
|
|
286
|
+
const logFilePath = storagePath("logs", "platforma.log");
|
|
289
287
|
if (!fs__default.existsSync(logFilePath)) {
|
|
290
288
|
fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
291
|
-
fs__default.writeFileSync(logFilePath,
|
|
289
|
+
fs__default.writeFileSync(logFilePath, "");
|
|
292
290
|
}
|
|
293
|
-
const presignHost = options?.presignHost ??
|
|
291
|
+
const presignHost = options?.presignHost ?? "localhost";
|
|
294
292
|
const presignPort = options?.s3Port ?? 9000;
|
|
295
293
|
const primary = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-primary-bucket`);
|
|
296
|
-
if (primary.type !==
|
|
297
|
-
throw new Error(
|
|
294
|
+
if (primary.type !== "S3") {
|
|
295
|
+
throw new Error("primary storage must have 'S3' type in 'docker s3' configuration");
|
|
298
296
|
}
|
|
299
297
|
else {
|
|
300
298
|
primary.presignEndpoint = `http://${presignHost}:${presignPort}`;
|
|
301
299
|
}
|
|
302
300
|
const library = storageSettingsFromURL(`s3e://testuser:testpassword@minio:${presignPort}/platforma-library-bucket`);
|
|
303
|
-
if (library.type !==
|
|
301
|
+
if (library.type !== "S3") {
|
|
304
302
|
throw new Error(`${library.type} storage type is not supported for library storage`);
|
|
305
303
|
}
|
|
306
304
|
else {
|
|
307
305
|
library.presignEndpoint = `http://${presignHost}:${presignPort}`;
|
|
308
306
|
}
|
|
309
|
-
const dbFSPath = storageDir(
|
|
310
|
-
const workFSPath = storageDir(
|
|
311
|
-
const usersFSPath = storagePath(
|
|
307
|
+
const dbFSPath = storageDir("db");
|
|
308
|
+
const workFSPath = storageDir("work");
|
|
309
|
+
const usersFSPath = storagePath("users.htpasswd");
|
|
312
310
|
if (!fs__default.existsSync(usersFSPath)) {
|
|
313
|
-
fs__default.copyFileSync(assets(
|
|
311
|
+
fs__default.copyFileSync(assets("users.htpasswd"), usersFSPath);
|
|
314
312
|
}
|
|
315
|
-
const composeDstPath = storagePath(
|
|
313
|
+
const composeDstPath = storagePath("compose.yaml");
|
|
316
314
|
if (fs__default.existsSync(composeDstPath)) {
|
|
317
315
|
this.logger.info(`replacing docker compose file ${composeDstPath}`);
|
|
318
316
|
}
|
|
@@ -324,35 +322,38 @@ class Core {
|
|
|
324
322
|
});
|
|
325
323
|
}
|
|
326
324
|
render$1(composeS3Path, composeDstPath, `pl-${instanceName}`, new Map([
|
|
327
|
-
[
|
|
328
|
-
[
|
|
325
|
+
["minio", {}],
|
|
326
|
+
[
|
|
327
|
+
"backend",
|
|
328
|
+
{
|
|
329
329
|
platform: options?.platformOverride,
|
|
330
330
|
mounts: backendMounts,
|
|
331
331
|
commands: options?.backendCommands,
|
|
332
|
-
}
|
|
332
|
+
},
|
|
333
|
+
],
|
|
333
334
|
]));
|
|
334
335
|
const envs = {
|
|
335
|
-
MINIO_IMAGE:
|
|
336
|
-
MINIO_STORAGE: storageDir(
|
|
336
|
+
MINIO_IMAGE: "quay.io/minio/minio",
|
|
337
|
+
MINIO_STORAGE: storageDir("minio"),
|
|
337
338
|
PL_IMAGE: image,
|
|
338
339
|
PL_AUTH_HTPASSWD: usersFSPath,
|
|
339
340
|
PL_LICENSE: options?.license,
|
|
340
341
|
PL_LICENSE_FILE: options?.licenseFile,
|
|
341
|
-
PL_LOG_LEVEL: options?.logLevel ??
|
|
342
|
+
PL_LOG_LEVEL: options?.logLevel ?? "info",
|
|
342
343
|
PL_LOG_DIR: path.dirname(logFilePath),
|
|
343
|
-
PL_LOG_ROTATION_ENABLED:
|
|
344
|
-
PL_RUNNER_WD_CACHE_ON_FAILURE:
|
|
344
|
+
PL_LOG_ROTATION_ENABLED: "true",
|
|
345
|
+
PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
|
|
345
346
|
PL_DATA_DB_ROOT: dbFSPath,
|
|
346
|
-
PL_DATA_PRIMARY_ROOT: storageDir(
|
|
347
|
-
PL_DATA_LIBRARY_ROOT: storageDir(
|
|
347
|
+
PL_DATA_PRIMARY_ROOT: storageDir("primary"),
|
|
348
|
+
PL_DATA_LIBRARY_ROOT: storageDir("library"),
|
|
348
349
|
PL_DATA_WORKDIR_ROOT: workFSPath,
|
|
349
350
|
// Mount packages storage as volume, because APFS is case-insensitive on Mac OS X and this breaks some pl software installation.
|
|
350
351
|
// PL_DATA_PACKAGE_ROOT: storageDir('packages'),
|
|
351
|
-
...this.configureDockerStorage(
|
|
352
|
-
...this.configureDockerStorage(
|
|
352
|
+
...this.configureDockerStorage("primary", primary),
|
|
353
|
+
...this.configureDockerStorage("library", library),
|
|
353
354
|
};
|
|
354
355
|
if (options?.grpcAddr) {
|
|
355
|
-
const addrParts = options.grpcAddr.split(
|
|
356
|
+
const addrParts = options.grpcAddr.split(":");
|
|
356
357
|
if (addrParts.length === 2) {
|
|
357
358
|
envs.PL_LISTEN_ADDRESS = addrParts[0];
|
|
358
359
|
envs.PL_LISTEN_PORT = addrParts[1];
|
|
@@ -365,7 +366,7 @@ class Core {
|
|
|
365
366
|
envs.PL_LISTEN_PORT = options.grpcPort.toString();
|
|
366
367
|
}
|
|
367
368
|
if (options?.monitoringAddr) {
|
|
368
|
-
const addrParts = options.monitoringAddr.split(
|
|
369
|
+
const addrParts = options.monitoringAddr.split(":");
|
|
369
370
|
if (addrParts.length === 2) {
|
|
370
371
|
envs.PL_MONITORING_IP = addrParts[0];
|
|
371
372
|
envs.PL_MONITORING_PORT = addrParts[1];
|
|
@@ -378,7 +379,7 @@ class Core {
|
|
|
378
379
|
envs.PL_MONITORING_PORT = options.monitoringPort.toString();
|
|
379
380
|
}
|
|
380
381
|
if (options?.debugAddr) {
|
|
381
|
-
const addrParts = options.debugAddr.split(
|
|
382
|
+
const addrParts = options.debugAddr.split(":");
|
|
382
383
|
if (addrParts.length === 2) {
|
|
383
384
|
envs.PL_DEBUG_IP = addrParts[0];
|
|
384
385
|
envs.PL_DEBUG_PORT = addrParts[1];
|
|
@@ -396,51 +397,64 @@ class Core {
|
|
|
396
397
|
envs.MINIO_CONSOLE_PORT = options.s3ConsolePort.toString();
|
|
397
398
|
if (options?.auth) {
|
|
398
399
|
if (options.auth.enabled) {
|
|
399
|
-
envs[
|
|
400
|
+
envs["PL_NO_AUTH"] = "false";
|
|
400
401
|
}
|
|
401
402
|
else {
|
|
402
|
-
envs[
|
|
403
|
+
envs["PL_NO_AUTH"] = "true";
|
|
403
404
|
}
|
|
404
405
|
if (options.auth.drivers) {
|
|
405
406
|
for (const drv of options.auth.drivers) {
|
|
406
|
-
if (drv.driver ===
|
|
407
|
-
envs[
|
|
408
|
-
drv.path =
|
|
407
|
+
if (drv.driver === "htpasswd") {
|
|
408
|
+
envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
|
|
409
|
+
drv.path = "/etc/platforma/users.htpasswd";
|
|
409
410
|
}
|
|
410
411
|
}
|
|
411
|
-
envs[
|
|
412
|
+
envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
415
|
// Process additional backend commands
|
|
415
416
|
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
416
|
-
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(
|
|
417
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
|
|
417
418
|
}
|
|
418
419
|
state.setInstanceInfo(instanceName, {
|
|
419
|
-
type:
|
|
420
|
-
upCommands: [
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
type: "docker",
|
|
421
|
+
upCommands: [
|
|
422
|
+
{
|
|
423
|
+
cmd: "docker",
|
|
424
|
+
args: [
|
|
425
|
+
"compose",
|
|
426
|
+
`--file=${composeDstPath}`,
|
|
427
|
+
"up",
|
|
428
|
+
"--detach",
|
|
429
|
+
"--remove-orphans",
|
|
430
|
+
"--pull=missing",
|
|
431
|
+
],
|
|
423
432
|
envs: envs,
|
|
424
|
-
runOpts: { stdio:
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
433
|
+
runOpts: { stdio: "inherit" },
|
|
434
|
+
},
|
|
435
|
+
],
|
|
436
|
+
downCommands: [
|
|
437
|
+
{
|
|
438
|
+
cmd: "docker",
|
|
439
|
+
args: ["compose", `--file=${composeDstPath}`, "down"],
|
|
429
440
|
envs: envs,
|
|
430
|
-
runOpts: { stdio:
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
441
|
+
runOpts: { stdio: "inherit" },
|
|
442
|
+
},
|
|
443
|
+
],
|
|
444
|
+
cleanupCommands: [
|
|
445
|
+
{
|
|
446
|
+
cmd: "docker",
|
|
447
|
+
args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
|
|
435
448
|
envs: envs,
|
|
436
|
-
runOpts: { stdio:
|
|
437
|
-
}
|
|
449
|
+
runOpts: { stdio: "inherit" },
|
|
450
|
+
},
|
|
451
|
+
],
|
|
438
452
|
runInfo: {
|
|
439
453
|
apiPort: options?.grpcPort,
|
|
440
454
|
apiAddr: options?.grpcAddr,
|
|
441
455
|
logPath: logFilePath,
|
|
442
456
|
primary: primary,
|
|
443
|
-
work: { type:
|
|
457
|
+
work: { type: "FS", rootPath: workFSPath },
|
|
444
458
|
library: library,
|
|
445
459
|
dbPath: dbFSPath,
|
|
446
460
|
},
|
|
@@ -448,30 +462,30 @@ class Core {
|
|
|
448
462
|
return state.getInstanceInfo(instanceName);
|
|
449
463
|
}
|
|
450
464
|
createDocker(instanceName, localRoot, options) {
|
|
451
|
-
this.logger.debug(
|
|
452
|
-
const composeFSPath = assets(
|
|
465
|
+
this.logger.debug("creating platforma instance in 'docker' mode...");
|
|
466
|
+
const composeFSPath = assets("compose-backend.yaml");
|
|
453
467
|
const image = options?.image ?? plImageTag(options?.version);
|
|
454
468
|
this.checkLicense(options?.license, options?.licenseFile);
|
|
455
469
|
const storagePath = (...s) => path.join(localRoot, ...s);
|
|
456
470
|
const storageDir = (s) => {
|
|
457
471
|
const p = storagePath(s);
|
|
458
|
-
ensureDir(p, { mode:
|
|
472
|
+
ensureDir(p, { mode: "0775" });
|
|
459
473
|
return p;
|
|
460
474
|
};
|
|
461
|
-
const logFilePath = storagePath(
|
|
475
|
+
const logFilePath = storagePath("logs", "platforma.log");
|
|
462
476
|
if (!fs__default.existsSync(logFilePath)) {
|
|
463
477
|
fs__default.mkdirSync(path.dirname(logFilePath), { recursive: true });
|
|
464
|
-
fs__default.writeFileSync(logFilePath,
|
|
478
|
+
fs__default.writeFileSync(logFilePath, "");
|
|
465
479
|
}
|
|
466
|
-
const dbFSPath = storageDir(
|
|
467
|
-
const primaryFSPath = storageDir(
|
|
468
|
-
const libraryFSPath = storageDir(
|
|
469
|
-
const workFSPath = storageDir(
|
|
470
|
-
const usersFSPath = storagePath(
|
|
480
|
+
const dbFSPath = storageDir("db");
|
|
481
|
+
const primaryFSPath = storageDir("primary");
|
|
482
|
+
const libraryFSPath = storageDir("library");
|
|
483
|
+
const workFSPath = storageDir("work");
|
|
484
|
+
const usersFSPath = storagePath("users.htpasswd");
|
|
471
485
|
if (!fs__default.existsSync(usersFSPath)) {
|
|
472
|
-
fs__default.copyFileSync(assets(
|
|
486
|
+
fs__default.copyFileSync(assets("users.htpasswd"), usersFSPath);
|
|
473
487
|
}
|
|
474
|
-
const composeDstPath = storagePath(
|
|
488
|
+
const composeDstPath = storagePath("compose.yaml");
|
|
475
489
|
if (fs__default.existsSync(composeDstPath)) {
|
|
476
490
|
this.logger.info(`replacing docker compose file ${composeDstPath}`);
|
|
477
491
|
}
|
|
@@ -484,33 +498,36 @@ class Core {
|
|
|
484
498
|
}
|
|
485
499
|
this.logger.debug(`Rendering docker compose file '${composeDstPath}' using '${composeFSPath}' as base template`);
|
|
486
500
|
render$1(composeFSPath, composeDstPath, `pl-${instanceName}`, new Map([
|
|
487
|
-
[
|
|
501
|
+
[
|
|
502
|
+
"backend",
|
|
503
|
+
{
|
|
488
504
|
platform: options?.platformOverride,
|
|
489
505
|
mounts: backendMounts,
|
|
490
506
|
commands: options?.backendCommands,
|
|
491
|
-
}
|
|
507
|
+
},
|
|
508
|
+
],
|
|
492
509
|
]));
|
|
493
|
-
const primary = storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`,
|
|
494
|
-
const library = storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`,
|
|
510
|
+
const primary = storageSettingsFromURL(options?.primaryStorageURL ?? `file:${primaryFSPath}`, ".");
|
|
511
|
+
const library = storageSettingsFromURL(options?.libraryStorageURL ?? `file:${libraryFSPath}`, ".");
|
|
495
512
|
const envs = {
|
|
496
513
|
PL_IMAGE: image,
|
|
497
514
|
PL_AUTH_HTPASSWD: usersFSPath,
|
|
498
515
|
PL_LICENSE: options?.license,
|
|
499
516
|
PL_LICENSE_FILE: options?.licenseFile,
|
|
500
|
-
PL_LOG_LEVEL: options?.logLevel ??
|
|
517
|
+
PL_LOG_LEVEL: options?.logLevel ?? "info",
|
|
501
518
|
PL_LOG_DIR: path.dirname(logFilePath),
|
|
502
|
-
PL_LOG_ROTATION_ENABLED:
|
|
503
|
-
PL_RUNNER_WD_CACHE_ON_FAILURE:
|
|
519
|
+
PL_LOG_ROTATION_ENABLED: "true",
|
|
520
|
+
PL_RUNNER_WD_CACHE_ON_FAILURE: "1h",
|
|
504
521
|
PL_DATA_DB_ROOT: dbFSPath,
|
|
505
522
|
PL_DATA_PRIMARY_ROOT: primaryFSPath,
|
|
506
523
|
PL_DATA_LIBRARY_ROOT: libraryFSPath,
|
|
507
524
|
PL_DATA_WORKDIR_ROOT: workFSPath,
|
|
508
|
-
PL_DATA_PACKAGE_ROOT: storageDir(
|
|
509
|
-
...this.configureDockerStorage(
|
|
510
|
-
...this.configureDockerStorage(
|
|
525
|
+
PL_DATA_PACKAGE_ROOT: storageDir("packages"),
|
|
526
|
+
...this.configureDockerStorage("primary", primary),
|
|
527
|
+
...this.configureDockerStorage("library", library),
|
|
511
528
|
};
|
|
512
529
|
if (options?.grpcAddr) {
|
|
513
|
-
const addrParts = options.grpcAddr.split(
|
|
530
|
+
const addrParts = options.grpcAddr.split(":");
|
|
514
531
|
if (addrParts.length === 2) {
|
|
515
532
|
envs.PL_LISTEN_ADDRESS = addrParts[0];
|
|
516
533
|
envs.PL_LISTEN_PORT = addrParts[1];
|
|
@@ -523,7 +540,7 @@ class Core {
|
|
|
523
540
|
envs.PL_LISTEN_PORT = options.grpcPort.toString();
|
|
524
541
|
}
|
|
525
542
|
if (options?.monitoringAddr) {
|
|
526
|
-
const addrParts = options.monitoringAddr.split(
|
|
543
|
+
const addrParts = options.monitoringAddr.split(":");
|
|
527
544
|
if (addrParts.length === 2) {
|
|
528
545
|
envs.PL_MONITORING_IP = addrParts[0];
|
|
529
546
|
envs.PL_MONITORING_PORT = addrParts[1];
|
|
@@ -536,7 +553,7 @@ class Core {
|
|
|
536
553
|
envs.PL_MONITORING_PORT = options.monitoringPort.toString();
|
|
537
554
|
}
|
|
538
555
|
if (options?.debugAddr) {
|
|
539
|
-
const addrParts = options.debugAddr.split(
|
|
556
|
+
const addrParts = options.debugAddr.split(":");
|
|
540
557
|
if (addrParts.length === 2) {
|
|
541
558
|
envs.PL_DEBUG_IP = addrParts[0];
|
|
542
559
|
envs.PL_DEBUG_PORT = addrParts[1];
|
|
@@ -550,51 +567,64 @@ class Core {
|
|
|
550
567
|
}
|
|
551
568
|
if (options?.auth) {
|
|
552
569
|
if (options.auth.enabled) {
|
|
553
|
-
envs[
|
|
570
|
+
envs["PL_NO_AUTH"] = "false";
|
|
554
571
|
}
|
|
555
572
|
else {
|
|
556
|
-
envs[
|
|
573
|
+
envs["PL_NO_AUTH"] = "true";
|
|
557
574
|
}
|
|
558
575
|
if (options.auth.drivers) {
|
|
559
576
|
for (const drv of options.auth.drivers) {
|
|
560
|
-
if (drv.driver ===
|
|
561
|
-
envs[
|
|
562
|
-
drv.path =
|
|
577
|
+
if (drv.driver === "htpasswd") {
|
|
578
|
+
envs["PL_AUTH_HTPASSWD"] = path.resolve(drv.path);
|
|
579
|
+
drv.path = "/etc/platforma/users.htpasswd";
|
|
563
580
|
}
|
|
564
581
|
}
|
|
565
|
-
envs[
|
|
582
|
+
envs["PL_AUTH_DRIVERS"] = JSON.stringify(options.auth.drivers);
|
|
566
583
|
}
|
|
567
584
|
}
|
|
568
585
|
// Process additional backend commands
|
|
569
586
|
if (options?.backendCommands && options.backendCommands.length > 0) {
|
|
570
|
-
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(
|
|
587
|
+
this.logger.debug(`Adding backend commands: ${options.backendCommands.join(" ")}`);
|
|
571
588
|
}
|
|
572
589
|
state.setInstanceInfo(instanceName, {
|
|
573
|
-
type:
|
|
574
|
-
upCommands: [
|
|
575
|
-
|
|
576
|
-
|
|
590
|
+
type: "docker",
|
|
591
|
+
upCommands: [
|
|
592
|
+
{
|
|
593
|
+
cmd: "docker",
|
|
594
|
+
args: [
|
|
595
|
+
"compose",
|
|
596
|
+
`--file=${composeDstPath}`,
|
|
597
|
+
"up",
|
|
598
|
+
"--detach",
|
|
599
|
+
"--remove-orphans",
|
|
600
|
+
"--pull=missing",
|
|
601
|
+
],
|
|
577
602
|
envs: envs,
|
|
578
|
-
runOpts: { stdio:
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
603
|
+
runOpts: { stdio: "inherit" },
|
|
604
|
+
},
|
|
605
|
+
],
|
|
606
|
+
downCommands: [
|
|
607
|
+
{
|
|
608
|
+
cmd: "docker",
|
|
609
|
+
args: ["compose", `--file=${composeDstPath}`, "down"],
|
|
583
610
|
envs: envs,
|
|
584
|
-
runOpts: { stdio:
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
611
|
+
runOpts: { stdio: "inherit" },
|
|
612
|
+
},
|
|
613
|
+
],
|
|
614
|
+
cleanupCommands: [
|
|
615
|
+
{
|
|
616
|
+
cmd: "docker",
|
|
617
|
+
args: ["compose", `--file=${composeDstPath}`, "down", "--volumes", "--remove-orphans"],
|
|
589
618
|
envs: envs,
|
|
590
|
-
runOpts: { stdio:
|
|
591
|
-
}
|
|
619
|
+
runOpts: { stdio: "inherit" },
|
|
620
|
+
},
|
|
621
|
+
],
|
|
592
622
|
runInfo: {
|
|
593
623
|
apiPort: options?.grpcPort,
|
|
594
624
|
apiAddr: options?.grpcAddr,
|
|
595
625
|
logPath: logFilePath,
|
|
596
626
|
primary: primary,
|
|
597
|
-
work: { type:
|
|
627
|
+
work: { type: "FS", rootPath: workFSPath },
|
|
598
628
|
library: library,
|
|
599
629
|
dbPath: dbFSPath,
|
|
600
630
|
},
|
|
@@ -604,17 +634,17 @@ class Core {
|
|
|
604
634
|
cleanupInstance(instanceName) {
|
|
605
635
|
const removeWarns = [];
|
|
606
636
|
const instancesToDrop = new Map();
|
|
607
|
-
let warnMessage =
|
|
637
|
+
let warnMessage = "";
|
|
608
638
|
if (instanceName) {
|
|
609
639
|
const instance = state.getInstanceInfo(instanceName);
|
|
610
640
|
instancesToDrop.set(instanceName, instance);
|
|
611
641
|
const iType = instance.type;
|
|
612
642
|
switch (iType) {
|
|
613
|
-
case
|
|
643
|
+
case "docker": {
|
|
614
644
|
removeWarns.push(`docker service 'pl-${instanceName}', including all its volumes and data in '${state.instanceDir(instanceName)}' will be destroyed`);
|
|
615
645
|
break;
|
|
616
646
|
}
|
|
617
|
-
case
|
|
647
|
+
case "process": {
|
|
618
648
|
removeWarns.push(`directory '${state.instanceDir(instanceName)}' would be deleted`);
|
|
619
649
|
if (instance.downCommands) {
|
|
620
650
|
removeWarns.push(`associated docker service, including all volumes and data will be destroyed`);
|
|
@@ -625,26 +655,26 @@ class Core {
|
|
|
625
655
|
assertNever();
|
|
626
656
|
}
|
|
627
657
|
if (instanceName === state.currentInstanceName) {
|
|
628
|
-
removeWarns.push(
|
|
658
|
+
removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)");
|
|
629
659
|
}
|
|
630
660
|
warnMessage = `
|
|
631
661
|
You are going to reset the state of platforma service '${instanceName}':
|
|
632
|
-
- ${removeWarns.join(
|
|
662
|
+
- ${removeWarns.join("\n - ")}
|
|
633
663
|
`;
|
|
634
664
|
}
|
|
635
665
|
else {
|
|
636
666
|
for (const iName of state.instanceList) {
|
|
637
667
|
instancesToDrop.set(iName, state.getInstanceInfo(iName));
|
|
638
668
|
}
|
|
639
|
-
removeWarns.push(
|
|
669
|
+
removeWarns.push("last command run cache ('pl-dev start' shorthand will stop working until next full start command call)", `all service configurations stored in: ${state.instanceDir()} (including all associated docker containers and volumes)`);
|
|
640
670
|
warnMessage = `
|
|
641
671
|
You are going to reset the state of all platforma services configured with pl-bootstrap package.
|
|
642
|
-
- ${removeWarns.join(
|
|
672
|
+
- ${removeWarns.join("\n - ")}
|
|
643
673
|
`;
|
|
644
674
|
}
|
|
645
675
|
this.logger.warn(warnMessage);
|
|
646
|
-
if (!askYN(
|
|
647
|
-
this.logger.info(
|
|
676
|
+
if (!askYN("Are you sure?")) {
|
|
677
|
+
this.logger.info("Reset action was canceled");
|
|
648
678
|
return;
|
|
649
679
|
}
|
|
650
680
|
for (const [name, instance] of instancesToDrop.entries()) {
|
|
@@ -664,62 +694,62 @@ You are going to reset the state of all platforma services configured with pl-bo
|
|
|
664
694
|
}
|
|
665
695
|
mergeLicenseEnvs(flags) {
|
|
666
696
|
if (flags.license === undefined) {
|
|
667
|
-
if ((process.env.MI_LICENSE ??
|
|
697
|
+
if ((process.env.MI_LICENSE ?? "") != "")
|
|
668
698
|
flags.license = process.env.MI_LICENSE;
|
|
669
|
-
else if ((process.env.PL_LICENSE ??
|
|
699
|
+
else if ((process.env.PL_LICENSE ?? "") != "")
|
|
670
700
|
flags.license = process.env.PL_LICENSE;
|
|
671
701
|
}
|
|
672
702
|
// set 'license-file' only if license is still undefined
|
|
673
|
-
if (flags[
|
|
674
|
-
if ((process.env.MI_LICENSE_FILE ??
|
|
675
|
-
flags[
|
|
676
|
-
else if ((process.env.PL_LICENSE_FILE ??
|
|
677
|
-
flags[
|
|
678
|
-
else if (fs__default.existsSync(path.resolve(os__default.homedir(),
|
|
679
|
-
flags[
|
|
703
|
+
if (flags["license-file"] === undefined && flags.license === undefined) {
|
|
704
|
+
if ((process.env.MI_LICENSE_FILE ?? "") != "")
|
|
705
|
+
flags["license-file"] = process.env.MI_LICENSE_FILE;
|
|
706
|
+
else if ((process.env.PL_LICENSE_FILE ?? "") != "")
|
|
707
|
+
flags["license-file"] = process.env.PL_LICENSE_FILE;
|
|
708
|
+
else if (fs__default.existsSync(path.resolve(os__default.homedir(), ".pl.license")))
|
|
709
|
+
flags["license-file"] = path.resolve(os__default.homedir(), ".pl.license");
|
|
680
710
|
}
|
|
681
711
|
}
|
|
682
712
|
initAuthDriversList(flags, workdir) {
|
|
683
713
|
const authDrivers = [];
|
|
684
|
-
if (flags[
|
|
714
|
+
if (flags["auth-htpasswd-file"]) {
|
|
685
715
|
authDrivers.push({
|
|
686
|
-
driver:
|
|
687
|
-
path: path.resolve(workdir, flags[
|
|
716
|
+
driver: "htpasswd",
|
|
717
|
+
path: path.resolve(workdir, flags["auth-htpasswd-file"]),
|
|
688
718
|
});
|
|
689
719
|
}
|
|
690
|
-
if (Boolean(flags[
|
|
691
|
-
throw new Error(
|
|
720
|
+
if (Boolean(flags["auth-ldap-server"]) !== Boolean(flags["auth-ldap-default-dn"])) {
|
|
721
|
+
throw new Error("LDAP auth settings require both 'server' and 'default DN' options to be set");
|
|
692
722
|
}
|
|
693
|
-
if (flags[
|
|
723
|
+
if (flags["auth-ldap-server"]) {
|
|
694
724
|
authDrivers.push({
|
|
695
|
-
driver:
|
|
696
|
-
serverUrl: flags[
|
|
697
|
-
defaultDN: flags[
|
|
725
|
+
driver: "ldap",
|
|
726
|
+
serverUrl: flags["auth-ldap-server"],
|
|
727
|
+
defaultDN: flags["auth-ldap-default-dn"],
|
|
698
728
|
});
|
|
699
729
|
}
|
|
700
730
|
if (authDrivers.length === 0) {
|
|
701
731
|
return undefined;
|
|
702
732
|
}
|
|
703
|
-
return [{ driver:
|
|
733
|
+
return [{ driver: "jwt", key: this.getLastJwt() }, ...authDrivers];
|
|
704
734
|
}
|
|
705
735
|
/** Gets the last stored JWT secret key or generates it and stores in a file. */
|
|
706
736
|
getLastJwt() {
|
|
707
|
-
const jwtFile = state.path(
|
|
708
|
-
const encoding =
|
|
709
|
-
let lastJwt =
|
|
737
|
+
const jwtFile = state.path("auth.jwt");
|
|
738
|
+
const encoding = "utf-8";
|
|
739
|
+
let lastJwt = "";
|
|
710
740
|
if (fs__default.existsSync(jwtFile)) {
|
|
711
741
|
lastJwt = fs__default.readFileSync(jwtFile, { encoding });
|
|
712
742
|
}
|
|
713
|
-
if (lastJwt ==
|
|
743
|
+
if (lastJwt == "") {
|
|
714
744
|
lastJwt = randomStr(64);
|
|
715
745
|
fs__default.writeFileSync(jwtFile, lastJwt, { encoding });
|
|
716
746
|
}
|
|
717
747
|
return lastJwt;
|
|
718
748
|
}
|
|
719
749
|
checkLicense(value, file) {
|
|
720
|
-
if (value !== undefined && value !=
|
|
750
|
+
if (value !== undefined && value != "")
|
|
721
751
|
return;
|
|
722
|
-
if (file !== undefined && file !=
|
|
752
|
+
if (file !== undefined && file != "")
|
|
723
753
|
return;
|
|
724
754
|
this.logger.error(`A license for Platforma Backend must be set.
|
|
725
755
|
|
|
@@ -739,55 +769,55 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
|
|
|
739
769
|
const sType = storage.type;
|
|
740
770
|
storageID = storageID.toUpperCase();
|
|
741
771
|
switch (sType) {
|
|
742
|
-
case
|
|
772
|
+
case "S3":
|
|
743
773
|
switch (storageID) {
|
|
744
|
-
case
|
|
774
|
+
case "PRIMARY": {
|
|
745
775
|
// Construct the S3 URL for primary storage
|
|
746
776
|
if (storage.endpoint && storage.bucketName) {
|
|
747
|
-
envs[
|
|
777
|
+
envs["PL_PRIMARY_STORAGE_S3"] = `${storage.endpoint}${storage.bucketName}`;
|
|
748
778
|
}
|
|
749
779
|
if (storage.endpoint)
|
|
750
|
-
envs[
|
|
780
|
+
envs["PL_PRIMARY_STORAGE_S3_ENDPOINT"] = storage.endpoint;
|
|
751
781
|
if (storage.presignEndpoint)
|
|
752
|
-
envs[
|
|
782
|
+
envs["PL_PRIMARY_STORAGE_S3_EXTERNAL_ENDPOINT"] = storage.presignEndpoint;
|
|
753
783
|
if (storage.region)
|
|
754
|
-
envs[
|
|
784
|
+
envs["PL_PRIMARY_STORAGE_S3_REGION"] = storage.region;
|
|
755
785
|
if (storage.key)
|
|
756
|
-
envs[
|
|
786
|
+
envs["PL_PRIMARY_STORAGE_S3_KEY"] = storage.key;
|
|
757
787
|
if (storage.secret)
|
|
758
|
-
envs[
|
|
788
|
+
envs["PL_PRIMARY_STORAGE_S3_SECRET"] = storage.secret;
|
|
759
789
|
break;
|
|
760
790
|
}
|
|
761
|
-
case
|
|
791
|
+
case "LIBRARY": {
|
|
762
792
|
// Construct the S3 URL for library storage
|
|
763
793
|
if (storage.endpoint && storage.bucketName) {
|
|
764
|
-
envs[
|
|
794
|
+
envs["PL_DATA_LIBRARY_S3_URL"] = `library=${storage.endpoint}${storage.bucketName}`;
|
|
765
795
|
}
|
|
766
796
|
if (storage.endpoint)
|
|
767
|
-
envs[
|
|
797
|
+
envs["PL_DATA_LIBRARY_S3_ENDPOINT"] = `library=${storage.endpoint}`;
|
|
768
798
|
if (storage.presignEndpoint)
|
|
769
|
-
envs[
|
|
799
|
+
envs["PL_DATA_LIBRARY_S3_EXTERNAL_ENDPOINT"] = `library=${storage.presignEndpoint}`;
|
|
770
800
|
if (storage.region)
|
|
771
|
-
envs[
|
|
801
|
+
envs["PL_DATA_LIBRARY_S3_REGION"] = `library=${storage.region}`;
|
|
772
802
|
if (storage.key)
|
|
773
|
-
envs[
|
|
803
|
+
envs["PL_DATA_LIBRARY_S3_KEY"] = `library=${storage.key}`;
|
|
774
804
|
if (storage.secret)
|
|
775
|
-
envs[
|
|
805
|
+
envs["PL_DATA_LIBRARY_S3_SECRET"] = `library=${storage.secret}`;
|
|
776
806
|
break;
|
|
777
807
|
}
|
|
778
808
|
default:
|
|
779
809
|
throw new Error(`Unknown storage ID: ${storageID}`);
|
|
780
810
|
}
|
|
781
811
|
return envs;
|
|
782
|
-
case
|
|
812
|
+
case "FS":
|
|
783
813
|
switch (storageID) {
|
|
784
|
-
case
|
|
814
|
+
case "PRIMARY":
|
|
785
815
|
if (storage.rootPath)
|
|
786
|
-
envs[
|
|
816
|
+
envs["PL_PRIMARY_STORAGE_FS"] = storage.rootPath;
|
|
787
817
|
break;
|
|
788
|
-
case
|
|
818
|
+
case "LIBRARY":
|
|
789
819
|
if (storage.rootPath)
|
|
790
|
-
envs[
|
|
820
|
+
envs["PL_DATA_LIBRARY_FS_PATH"] = storage.rootPath;
|
|
791
821
|
break;
|
|
792
822
|
default:
|
|
793
823
|
throw new Error(`Unknown storage ID: ${storageID}`);
|
|
@@ -800,31 +830,31 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
|
|
|
800
830
|
}
|
|
801
831
|
renderRunInfo(runInfo, indent = 10) {
|
|
802
832
|
const report = [];
|
|
803
|
-
const column = (t) => t.padStart(indent,
|
|
833
|
+
const column = (t) => t.padStart(indent, " ");
|
|
804
834
|
if (runInfo.configPath) {
|
|
805
|
-
report.push(`${column(
|
|
835
|
+
report.push(`${column("config")}: ${runInfo.configPath}`);
|
|
806
836
|
}
|
|
807
837
|
if (runInfo.apiAddr) {
|
|
808
|
-
report.push(`${column(
|
|
838
|
+
report.push(`${column("API")}: ${runInfo.apiAddr}`);
|
|
809
839
|
}
|
|
810
840
|
else if (runInfo.apiPort) {
|
|
811
|
-
report.push(`${column(
|
|
841
|
+
report.push(`${column("API")}: 127.0.0.1:${runInfo.apiPort.toString()}`);
|
|
812
842
|
}
|
|
813
843
|
else {
|
|
814
|
-
report.push(`${column(
|
|
844
|
+
report.push(`${column("API")}: 127.0.0.1:6345`);
|
|
815
845
|
}
|
|
816
846
|
if (runInfo.logPath) {
|
|
817
|
-
report.push(`${column(
|
|
847
|
+
report.push(`${column("log")}: ${runInfo.logPath}`);
|
|
818
848
|
}
|
|
819
849
|
const primaryType = runInfo.primary?.type;
|
|
820
850
|
switch (primaryType) {
|
|
821
851
|
case undefined:
|
|
822
852
|
break;
|
|
823
|
-
case
|
|
824
|
-
report.push(`${column(
|
|
853
|
+
case "FS":
|
|
854
|
+
report.push(`${column("primary")}: ${runInfo.primary.rootPath}`);
|
|
825
855
|
break;
|
|
826
|
-
case
|
|
827
|
-
report.push(`${column(
|
|
856
|
+
case "S3":
|
|
857
|
+
report.push(`${column("primary")}: S3 at '${runInfo.primary.endpoint ?? "AWS"}', bucket '${runInfo.primary.bucketName}', prefix: '${runInfo.primary.keyPrefix ?? ""}'`);
|
|
828
858
|
break;
|
|
829
859
|
default:
|
|
830
860
|
assertNever();
|
|
@@ -833,22 +863,22 @@ You can obtain the license from "https://platforma.bio/getlicense".`);
|
|
|
833
863
|
switch (libraryType) {
|
|
834
864
|
case undefined:
|
|
835
865
|
break;
|
|
836
|
-
case
|
|
837
|
-
report.push(`${column(
|
|
866
|
+
case "FS":
|
|
867
|
+
report.push(`${column("library")}: ${runInfo.library.rootPath}`);
|
|
838
868
|
break;
|
|
839
|
-
case
|
|
840
|
-
report.push(`${column(
|
|
869
|
+
case "S3":
|
|
870
|
+
report.push(`${column("library")}: S3 at '${runInfo.library.endpoint ?? "AWS"}', bucket '${runInfo.library.bucketName}', prefix: '${runInfo.library.keyPrefix ?? ""}'`);
|
|
841
871
|
break;
|
|
842
872
|
default:
|
|
843
873
|
assertNever();
|
|
844
874
|
}
|
|
845
875
|
if (runInfo.work) {
|
|
846
|
-
report.push(`${column(
|
|
876
|
+
report.push(`${column("workdirs")}: ${runInfo.work.rootPath}`);
|
|
847
877
|
}
|
|
848
878
|
if (runInfo.dbPath) {
|
|
849
|
-
report.push(`${column(
|
|
879
|
+
report.push(`${column("db")}: ${runInfo.dbPath}`);
|
|
850
880
|
}
|
|
851
|
-
return report.join(
|
|
881
|
+
return report.join("\n");
|
|
852
882
|
}
|
|
853
883
|
}
|
|
854
884
|
function checkRunError(result, message) {
|
|
@@ -856,7 +886,7 @@ function checkRunError(result, message) {
|
|
|
856
886
|
if (buffer.error) {
|
|
857
887
|
throw buffer.error;
|
|
858
888
|
}
|
|
859
|
-
const msg = message ??
|
|
889
|
+
const msg = message ?? "failed to run command";
|
|
860
890
|
if (buffer.status !== 0) {
|
|
861
891
|
throw new Error(`${msg}, process exited with code '${buffer.status}'`);
|
|
862
892
|
}
|