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