@platformatic/runtime 2.44.5 → 2.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.d.ts +2 -1
- package/lib/config.js +1 -1
- package/lib/management-api.js +1 -1
- package/lib/prom-server.js +3 -0
- package/lib/runtime.js +133 -42
- package/lib/schema.js +10 -3
- package/lib/worker/itc.js +10 -6
- package/lib/worker/symbols.js +2 -0
- package/package.json +16 -15
- package/schema.json +11 -22
package/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type HttpsSchemasPlatformaticDevPlatformaticRuntime2460Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
|
@@ -163,6 +163,7 @@ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2445Json = {
|
|
|
163
163
|
| boolean
|
|
164
164
|
| {
|
|
165
165
|
port?: number | string;
|
|
166
|
+
enabled?: boolean | string;
|
|
166
167
|
hostname?: string;
|
|
167
168
|
endpoint?: string;
|
|
168
169
|
auth?: {
|
package/lib/config.js
CHANGED
|
@@ -70,7 +70,7 @@ async function _transformConfig (configManager, args) {
|
|
|
70
70
|
config = join(entryPath, configFilename)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const service = { id, config, path: entryPath, useHttp: !!mapping.useHttp }
|
|
73
|
+
const service = { id, config, path: entryPath, useHttp: !!mapping.useHttp, health: mapping.health }
|
|
74
74
|
const existingServiceId = services.findIndex(service => service.id === id)
|
|
75
75
|
|
|
76
76
|
if (existingServiceId !== -1) {
|
package/lib/management-api.js
CHANGED
package/lib/prom-server.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
const fastify = require('fastify')
|
|
4
4
|
|
|
5
5
|
async function startPrometheusServer (runtime, opts) {
|
|
6
|
+
if (opts.enabled === false) {
|
|
7
|
+
return
|
|
8
|
+
}
|
|
6
9
|
const host = opts.hostname ?? '0.0.0.0'
|
|
7
10
|
const port = opts.port ?? 9090
|
|
8
11
|
const metricsEndpoint = opts.endpoint ?? '/metrics'
|
package/lib/runtime.js
CHANGED
|
@@ -26,6 +26,7 @@ const { sendViaITC, waitEventFromITC } = require('./worker/itc')
|
|
|
26
26
|
const { RoundRobinMap } = require('./worker/round-robin-map.js')
|
|
27
27
|
const {
|
|
28
28
|
kId,
|
|
29
|
+
kFullId,
|
|
29
30
|
kServiceId,
|
|
30
31
|
kWorkerId,
|
|
31
32
|
kITC,
|
|
@@ -274,10 +275,22 @@ class Runtime extends EventEmitter {
|
|
|
274
275
|
await this.#inspectorServer.close()
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
|
|
278
|
+
// Stop the entrypoint first so that no new requests are accepted
|
|
279
|
+
if (this.#entrypointId) {
|
|
280
|
+
await this.stopService(this.#entrypointId, silent)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Stop services in reverse order to ensure services which depend on others are stopped first
|
|
284
|
+
for (const service of this.#servicesIds.reverse()) {
|
|
285
|
+
// The entrypoint has been stopped above
|
|
286
|
+
if (service === this.#entrypointId) {
|
|
287
|
+
continue
|
|
288
|
+
}
|
|
289
|
+
|
|
278
290
|
await this.stopService(service, silent)
|
|
279
291
|
}
|
|
280
292
|
|
|
293
|
+
await this.#meshInterceptor.close()
|
|
281
294
|
this.#updateStatus('stopped')
|
|
282
295
|
}
|
|
283
296
|
|
|
@@ -285,6 +298,7 @@ class Runtime extends EventEmitter {
|
|
|
285
298
|
this.emit('restarting')
|
|
286
299
|
|
|
287
300
|
await this.stop()
|
|
301
|
+
this.#meshInterceptor.restart()
|
|
288
302
|
await this.start()
|
|
289
303
|
|
|
290
304
|
this.emit('restarted')
|
|
@@ -296,7 +310,7 @@ class Runtime extends EventEmitter {
|
|
|
296
310
|
return this.#status
|
|
297
311
|
}
|
|
298
312
|
|
|
299
|
-
async close (
|
|
313
|
+
async close (silent = false) {
|
|
300
314
|
this.#updateStatus('closing')
|
|
301
315
|
|
|
302
316
|
clearInterval(this.#metricsTimeout)
|
|
@@ -304,14 +318,10 @@ class Runtime extends EventEmitter {
|
|
|
304
318
|
await this.stop(silent)
|
|
305
319
|
|
|
306
320
|
if (this.#managementApi) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
})
|
|
312
|
-
} else {
|
|
313
|
-
await this.#managementApi.close()
|
|
314
|
-
}
|
|
321
|
+
// This allow a close request coming from the management API to correctly be handled
|
|
322
|
+
setImmediate(() => {
|
|
323
|
+
this.#managementApi.close()
|
|
324
|
+
})
|
|
315
325
|
}
|
|
316
326
|
|
|
317
327
|
if (this.#prometheusServer) {
|
|
@@ -1006,7 +1016,7 @@ class Runtime extends EventEmitter {
|
|
|
1006
1016
|
this.emit('service:init', id)
|
|
1007
1017
|
}
|
|
1008
1018
|
|
|
1009
|
-
async #setupWorker (config, serviceConfig, workersCount, serviceId, index) {
|
|
1019
|
+
async #setupWorker (config, serviceConfig, workersCount, serviceId, index, enabled = true) {
|
|
1010
1020
|
const { restartOnError } = config
|
|
1011
1021
|
const workerId = `${serviceId}:${index}`
|
|
1012
1022
|
|
|
@@ -1096,7 +1106,7 @@ class Runtime extends EventEmitter {
|
|
|
1096
1106
|
worker[kWorkerStatus] = 'exited'
|
|
1097
1107
|
this.emit('service:worker:exited', eventPayload)
|
|
1098
1108
|
|
|
1099
|
-
this.#cleanupWorker(
|
|
1109
|
+
this.#cleanupWorker(worker)
|
|
1100
1110
|
|
|
1101
1111
|
if (this.#status === 'stopping') {
|
|
1102
1112
|
return
|
|
@@ -1130,8 +1140,10 @@ class Runtime extends EventEmitter {
|
|
|
1130
1140
|
})
|
|
1131
1141
|
|
|
1132
1142
|
worker[kId] = workersCount > 1 ? workerId : serviceId
|
|
1143
|
+
worker[kFullId] = workerId
|
|
1133
1144
|
worker[kServiceId] = serviceId
|
|
1134
1145
|
worker[kWorkerId] = workersCount > 1 ? index : undefined
|
|
1146
|
+
worker[kWorkerStatus] = 'boot'
|
|
1135
1147
|
worker[kForwardEvents] = false
|
|
1136
1148
|
|
|
1137
1149
|
if (inspectorOptions) {
|
|
@@ -1190,19 +1202,21 @@ class Runtime extends EventEmitter {
|
|
|
1190
1202
|
})
|
|
1191
1203
|
}
|
|
1192
1204
|
|
|
1193
|
-
|
|
1194
|
-
|
|
1205
|
+
if (enabled) {
|
|
1206
|
+
// Store locally
|
|
1207
|
+
this.#workers.set(workerId, worker)
|
|
1195
1208
|
|
|
1196
|
-
|
|
1197
|
-
this.#
|
|
1209
|
+
// Setup the interceptor
|
|
1210
|
+
this.#meshInterceptor.route(serviceId, worker)
|
|
1198
1211
|
}
|
|
1199
1212
|
|
|
1200
|
-
// Setup the interceptor
|
|
1201
|
-
this.#meshInterceptor.route(serviceId, worker)
|
|
1202
|
-
|
|
1203
1213
|
// Store dependencies
|
|
1204
1214
|
const [{ dependencies }] = await waitEventFromITC(worker, 'init')
|
|
1205
1215
|
|
|
1216
|
+
if (serviceConfig.entrypoint) {
|
|
1217
|
+
this.#entrypointId = serviceId
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1206
1220
|
serviceConfig.dependencies = dependencies
|
|
1207
1221
|
for (const { envVar, url } of dependencies) {
|
|
1208
1222
|
if (envVar) {
|
|
@@ -1212,11 +1226,13 @@ class Runtime extends EventEmitter {
|
|
|
1212
1226
|
|
|
1213
1227
|
// This must be done here as the dependencies are filled above
|
|
1214
1228
|
worker[kConfig] = { ...serviceConfig, health }
|
|
1215
|
-
worker[kWorkerStatus] = '
|
|
1216
|
-
this.emit('service:worker:
|
|
1229
|
+
worker[kWorkerStatus] = 'init'
|
|
1230
|
+
this.emit('service:worker:init', eventPayload)
|
|
1231
|
+
|
|
1232
|
+
return worker
|
|
1217
1233
|
}
|
|
1218
1234
|
|
|
1219
|
-
#setupHealthCheck (worker, errorLabel) {
|
|
1235
|
+
#setupHealthCheck (config, serviceConfig, workersCount, id, index, workerId, worker, errorLabel) {
|
|
1220
1236
|
// Clear the timeout when exiting
|
|
1221
1237
|
worker.on('exit', () => clearTimeout(worker[kHealthCheckTimer]))
|
|
1222
1238
|
|
|
@@ -1229,9 +1245,10 @@ class Runtime extends EventEmitter {
|
|
|
1229
1245
|
const memoryUsage = heapUsed / maxHeapTotal
|
|
1230
1246
|
const unhealthy = elu > maxELU || memoryUsage > maxHeapUsed
|
|
1231
1247
|
|
|
1248
|
+
const serviceId = worker[kServiceId]
|
|
1232
1249
|
this.emit('health', {
|
|
1233
1250
|
id: worker[kId],
|
|
1234
|
-
service:
|
|
1251
|
+
service: serviceId,
|
|
1235
1252
|
worker: worker[kWorkerId],
|
|
1236
1253
|
currentHealth: health,
|
|
1237
1254
|
unhealthy,
|
|
@@ -1256,20 +1273,39 @@ class Runtime extends EventEmitter {
|
|
|
1256
1273
|
unhealthyChecks = 0
|
|
1257
1274
|
}
|
|
1258
1275
|
|
|
1259
|
-
if (unhealthyChecks
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1276
|
+
if (unhealthyChecks === maxUnhealthyChecks) {
|
|
1277
|
+
try {
|
|
1278
|
+
this.logger.error(
|
|
1279
|
+
{ elu, maxELU, memoryUsage, maxMemoryUsage: maxHeapUsed },
|
|
1280
|
+
`The ${errorLabel} is unhealthy. Replacing it ...`
|
|
1281
|
+
)
|
|
1282
|
+
|
|
1283
|
+
await this.#replaceWorker(config, serviceConfig, workersCount, id, index, workerId, worker)
|
|
1284
|
+
} catch (e) {
|
|
1285
|
+
this.logger.error(
|
|
1286
|
+
{ elu, maxELU, memoryUsage, maxMemoryUsage: maxHeapUsed },
|
|
1287
|
+
`Cannot replace the ${errorLabel}. Forcefully terminating it ...`
|
|
1288
|
+
)
|
|
1267
1289
|
|
|
1268
|
-
|
|
1290
|
+
worker.terminate()
|
|
1291
|
+
}
|
|
1292
|
+
} else {
|
|
1293
|
+
worker[kHealthCheckTimer].refresh()
|
|
1294
|
+
}
|
|
1269
1295
|
}, interval)
|
|
1270
1296
|
}
|
|
1271
1297
|
|
|
1272
|
-
async #startWorker (
|
|
1298
|
+
async #startWorker (
|
|
1299
|
+
config,
|
|
1300
|
+
serviceConfig,
|
|
1301
|
+
workersCount,
|
|
1302
|
+
id,
|
|
1303
|
+
index,
|
|
1304
|
+
silent,
|
|
1305
|
+
bootstrapAttempt = 0,
|
|
1306
|
+
worker = undefined,
|
|
1307
|
+
disableRestartAttempts = false
|
|
1308
|
+
) {
|
|
1273
1309
|
const workerId = `${id}:${index}`
|
|
1274
1310
|
const label = this.#workerExtendedLabel(id, index, workersCount)
|
|
1275
1311
|
|
|
@@ -1277,7 +1313,10 @@ class Runtime extends EventEmitter {
|
|
|
1277
1313
|
this.logger?.info(`Starting the ${label}...`)
|
|
1278
1314
|
}
|
|
1279
1315
|
|
|
1280
|
-
|
|
1316
|
+
if (!worker) {
|
|
1317
|
+
worker = await this.#getWorkerById(id, index, false, false)
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1281
1320
|
const eventPayload = { service: id, worker: index, workersCount }
|
|
1282
1321
|
|
|
1283
1322
|
// The service was stopped, recreate the thread
|
|
@@ -1321,7 +1360,7 @@ class Runtime extends EventEmitter {
|
|
|
1321
1360
|
if (enabled && config.restartOnError > 0) {
|
|
1322
1361
|
worker[kHealthCheckTimer] = setTimeout(
|
|
1323
1362
|
() => {
|
|
1324
|
-
this.#setupHealthCheck(worker, label)
|
|
1363
|
+
this.#setupHealthCheck(config, serviceConfig, workersCount, id, index, workerId, worker, label)
|
|
1325
1364
|
},
|
|
1326
1365
|
gracePeriod > 0 ? gracePeriod : 1
|
|
1327
1366
|
)
|
|
@@ -1330,7 +1369,7 @@ class Runtime extends EventEmitter {
|
|
|
1330
1369
|
// TODO: handle port allocation error here
|
|
1331
1370
|
if (error.code === 'EADDRINUSE') throw error
|
|
1332
1371
|
|
|
1333
|
-
this.#cleanupWorker(
|
|
1372
|
+
this.#cleanupWorker(worker)
|
|
1334
1373
|
|
|
1335
1374
|
if (worker[kWorkerStatus] !== 'exited') {
|
|
1336
1375
|
// This prevent the exit handler to restart service
|
|
@@ -1346,7 +1385,7 @@ class Runtime extends EventEmitter {
|
|
|
1346
1385
|
|
|
1347
1386
|
const restartOnError = config.restartOnError
|
|
1348
1387
|
|
|
1349
|
-
if (!restartOnError) {
|
|
1388
|
+
if (disableRestartAttempts || !restartOnError) {
|
|
1350
1389
|
throw error
|
|
1351
1390
|
}
|
|
1352
1391
|
|
|
@@ -1369,13 +1408,20 @@ class Runtime extends EventEmitter {
|
|
|
1369
1408
|
}
|
|
1370
1409
|
}
|
|
1371
1410
|
|
|
1372
|
-
async #stopWorker (workersCount, id, index, silent) {
|
|
1373
|
-
|
|
1411
|
+
async #stopWorker (workersCount, id, index, silent, worker = undefined) {
|
|
1412
|
+
if (!worker) {
|
|
1413
|
+
worker = await this.#getWorkerById(id, index, false, false)
|
|
1414
|
+
}
|
|
1374
1415
|
|
|
1375
1416
|
if (!worker) {
|
|
1376
1417
|
return
|
|
1377
1418
|
}
|
|
1378
1419
|
|
|
1420
|
+
// Boot should be aborted, discard the worker
|
|
1421
|
+
if (worker[kWorkerStatus] === 'boot') {
|
|
1422
|
+
return this.#discardWorker(worker)
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1379
1425
|
const eventPayload = { service: id, worker: index, workersCount }
|
|
1380
1426
|
|
|
1381
1427
|
worker[kWorkerStatus] = 'stopping'
|
|
@@ -1419,12 +1465,24 @@ class Runtime extends EventEmitter {
|
|
|
1419
1465
|
this.emit('service:worker:stopped', eventPayload)
|
|
1420
1466
|
}
|
|
1421
1467
|
|
|
1422
|
-
#cleanupWorker (
|
|
1423
|
-
|
|
1468
|
+
#cleanupWorker (worker) {
|
|
1469
|
+
clearTimeout(worker[kHealthCheckTimer])
|
|
1470
|
+
|
|
1471
|
+
const currentWorker = this.#workers.get(worker[kFullId])
|
|
1472
|
+
|
|
1473
|
+
if (currentWorker === worker) {
|
|
1474
|
+
this.#workers.delete(worker[kFullId])
|
|
1475
|
+
}
|
|
1424
1476
|
|
|
1425
1477
|
worker[kITC].close()
|
|
1478
|
+
}
|
|
1426
1479
|
|
|
1427
|
-
|
|
1480
|
+
async #discardWorker (worker) {
|
|
1481
|
+
this.#meshInterceptor.unroute(worker[kServiceId], worker, true)
|
|
1482
|
+
worker.removeAllListeners('exit')
|
|
1483
|
+
await worker.terminate()
|
|
1484
|
+
|
|
1485
|
+
return this.#cleanupWorker(worker)
|
|
1428
1486
|
}
|
|
1429
1487
|
|
|
1430
1488
|
#workerExtendedLabel (serviceId, workerId, workersCount) {
|
|
@@ -1476,6 +1534,39 @@ class Runtime extends EventEmitter {
|
|
|
1476
1534
|
await restartPromise
|
|
1477
1535
|
}
|
|
1478
1536
|
|
|
1537
|
+
async #replaceWorker (config, serviceConfig, workersCount, serviceId, index, workerId, worker) {
|
|
1538
|
+
let newWorker
|
|
1539
|
+
|
|
1540
|
+
try {
|
|
1541
|
+
// Create a new worker
|
|
1542
|
+
newWorker = await this.#setupWorker(config, serviceConfig, workersCount, serviceId, index, false)
|
|
1543
|
+
|
|
1544
|
+
// Make sure the runtime hasn't been stopped in the meanwhile
|
|
1545
|
+
if (this.#status !== 'started') {
|
|
1546
|
+
return this.#discardWorker(newWorker)
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1549
|
+
// Add the worker to the mesh
|
|
1550
|
+
await this.#startWorker(config, serviceConfig, workersCount, serviceId, index, false, 0, newWorker, true)
|
|
1551
|
+
|
|
1552
|
+
// Make sure the runtime hasn't been stopped in the meanwhile
|
|
1553
|
+
if (this.#status !== 'started') {
|
|
1554
|
+
return this.#discardWorker(newWorker)
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
this.#workers.set(workerId, newWorker)
|
|
1558
|
+
this.#meshInterceptor.route(serviceId, newWorker)
|
|
1559
|
+
|
|
1560
|
+
// Remove the old worker and then kill it
|
|
1561
|
+
await sendViaITC(worker, 'removeFromMesh')
|
|
1562
|
+
} catch (e) {
|
|
1563
|
+
newWorker?.terminate?.()
|
|
1564
|
+
throw e
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
await this.#stopWorker(workersCount, serviceId, index, false, worker)
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1479
1570
|
async #getServiceById (serviceId, ensureStarted = false, mustExist = true) {
|
|
1480
1571
|
// If the serviceId includes the worker, properly split
|
|
1481
1572
|
let workerId
|
package/lib/schema.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const telemetry = require('@platformatic/telemetry').schema
|
|
5
5
|
const {
|
|
6
|
-
schemaComponents: { server, logger, health }
|
|
6
|
+
schemaComponents: { server, logger, health, healthWithoutDefaults }
|
|
7
7
|
} = require('@platformatic/utils')
|
|
8
8
|
|
|
9
9
|
const env = {
|
|
@@ -65,7 +65,7 @@ const services = {
|
|
|
65
65
|
type: 'boolean'
|
|
66
66
|
},
|
|
67
67
|
workers,
|
|
68
|
-
health: { ...
|
|
68
|
+
health: { ...healthWithoutDefaults, default: undefined },
|
|
69
69
|
arguments: {
|
|
70
70
|
type: 'array',
|
|
71
71
|
items: {
|
|
@@ -174,7 +174,7 @@ const platformaticRuntimeSchema = {
|
|
|
174
174
|
type: 'boolean'
|
|
175
175
|
},
|
|
176
176
|
workers,
|
|
177
|
-
health: { ...
|
|
177
|
+
health: { ...healthWithoutDefaults, default: undefined },
|
|
178
178
|
preload,
|
|
179
179
|
arguments: {
|
|
180
180
|
type: 'array',
|
|
@@ -359,6 +359,13 @@ const platformaticRuntimeSchema = {
|
|
|
359
359
|
port: {
|
|
360
360
|
anyOf: [{ type: 'integer' }, { type: 'string' }]
|
|
361
361
|
},
|
|
362
|
+
enabled: {
|
|
363
|
+
anyOf: [{
|
|
364
|
+
type: 'boolean'
|
|
365
|
+
}, {
|
|
366
|
+
type: 'string'
|
|
367
|
+
}]
|
|
368
|
+
},
|
|
362
369
|
hostname: { type: 'string' },
|
|
363
370
|
endpoint: { type: 'string' },
|
|
364
371
|
auth: {
|
package/lib/worker/itc.js
CHANGED
|
@@ -86,14 +86,14 @@ function setupITC (app, service, dispatcher) {
|
|
|
86
86
|
await once(app, 'start')
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
if (status
|
|
89
|
+
if (status.startsWith('start')) {
|
|
90
90
|
// This gives a chance to a stackable to perform custom logic
|
|
91
91
|
globalThis.platformatic.events.emit('stop')
|
|
92
92
|
|
|
93
93
|
await app.stop()
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
dispatcher.interceptor.close()
|
|
96
|
+
await dispatcher.interceptor.close()
|
|
97
97
|
itc.close()
|
|
98
98
|
},
|
|
99
99
|
|
|
@@ -101,6 +101,14 @@ function setupITC (app, service, dispatcher) {
|
|
|
101
101
|
return app.stackable.build()
|
|
102
102
|
},
|
|
103
103
|
|
|
104
|
+
async removeFromMesh () {
|
|
105
|
+
return dispatcher.interceptor.close()
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
inject (injectParams) {
|
|
109
|
+
return app.stackable.inject(injectParams)
|
|
110
|
+
},
|
|
111
|
+
|
|
104
112
|
getStatus () {
|
|
105
113
|
return app.getStatus()
|
|
106
114
|
},
|
|
@@ -158,10 +166,6 @@ function setupITC (app, service, dispatcher) {
|
|
|
158
166
|
} catch (err) {
|
|
159
167
|
throw new errors.FailedToRetrieveHealthError(service.id, err.message)
|
|
160
168
|
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
inject (injectParams) {
|
|
164
|
-
return app.stackable.inject(injectParams)
|
|
165
169
|
}
|
|
166
170
|
}
|
|
167
171
|
})
|
package/lib/worker/symbols.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const kConfig = Symbol.for('plt.runtime.config')
|
|
4
4
|
const kId = Symbol.for('plt.runtime.id') // This is also used to detect if we are running in a Platformatic runtime thread
|
|
5
|
+
const kFullId = Symbol.for('plt.runtime.fullId')
|
|
5
6
|
const kServiceId = Symbol.for('plt.runtime.service.id')
|
|
6
7
|
const kWorkerId = Symbol.for('plt.runtime.worker.id')
|
|
7
8
|
const kITC = Symbol.for('plt.runtime.itc')
|
|
@@ -14,6 +15,7 @@ const kStderrMarker = '\ue002'
|
|
|
14
15
|
module.exports = {
|
|
15
16
|
kConfig,
|
|
16
17
|
kId,
|
|
18
|
+
kFullId,
|
|
17
19
|
kServiceId,
|
|
18
20
|
kWorkerId,
|
|
19
21
|
kITC,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.46.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@fastify/compress": "^8.0.0",
|
|
21
21
|
"@fastify/express": "^4.0.0",
|
|
22
22
|
"@fastify/formbody": "^8.0.0",
|
|
23
|
+
"autocannon": "^8.0.0",
|
|
23
24
|
"borp": "^0.19.0",
|
|
24
25
|
"c8": "^10.0.0",
|
|
25
26
|
"eslint": "9",
|
|
@@ -36,12 +37,12 @@
|
|
|
36
37
|
"typescript": "^5.5.4",
|
|
37
38
|
"undici-oidc-interceptor": "^0.5.0",
|
|
38
39
|
"why-is-node-running": "^2.2.2",
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/sql-
|
|
43
|
-
"@platformatic/
|
|
44
|
-
"@platformatic/
|
|
40
|
+
"@platformatic/db": "2.46.0",
|
|
41
|
+
"@platformatic/composer": "2.46.0",
|
|
42
|
+
"@platformatic/node": "2.46.0",
|
|
43
|
+
"@platformatic/sql-mapper": "2.46.0",
|
|
44
|
+
"@platformatic/sql-graphql": "2.46.0",
|
|
45
|
+
"@platformatic/service": "2.46.0"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
48
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -73,15 +74,15 @@
|
|
|
73
74
|
"tail-file-stream": "^0.2.0",
|
|
74
75
|
"thread-cpu-usage": "^0.2.0",
|
|
75
76
|
"undici": "^7.0.0",
|
|
76
|
-
"undici-thread-interceptor": "^0.
|
|
77
|
+
"undici-thread-interceptor": "^0.13.1",
|
|
77
78
|
"ws": "^8.16.0",
|
|
78
|
-
"@platformatic/basic": "2.
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/telemetry": "2.
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/utils": "2.
|
|
79
|
+
"@platformatic/basic": "2.46.0",
|
|
80
|
+
"@platformatic/config": "2.46.0",
|
|
81
|
+
"@platformatic/generators": "2.46.0",
|
|
82
|
+
"@platformatic/telemetry": "2.46.0",
|
|
83
|
+
"@platformatic/itc": "2.46.0",
|
|
84
|
+
"@platformatic/ts-compiler": "2.46.0",
|
|
85
|
+
"@platformatic/utils": "2.46.0"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.46.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
@@ -78,7 +78,6 @@
|
|
|
78
78
|
"type": "object",
|
|
79
79
|
"properties": {
|
|
80
80
|
"enabled": {
|
|
81
|
-
"default": true,
|
|
82
81
|
"anyOf": [
|
|
83
82
|
{
|
|
84
83
|
"type": "boolean"
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
]
|
|
90
89
|
},
|
|
91
90
|
"interval": {
|
|
92
|
-
"default": 30000,
|
|
93
91
|
"anyOf": [
|
|
94
92
|
{
|
|
95
93
|
"type": "number",
|
|
@@ -101,7 +99,6 @@
|
|
|
101
99
|
]
|
|
102
100
|
},
|
|
103
101
|
"gracePeriod": {
|
|
104
|
-
"default": 30000,
|
|
105
102
|
"anyOf": [
|
|
106
103
|
{
|
|
107
104
|
"type": "number",
|
|
@@ -113,7 +110,6 @@
|
|
|
113
110
|
]
|
|
114
111
|
},
|
|
115
112
|
"maxUnhealthyChecks": {
|
|
116
|
-
"default": 10,
|
|
117
113
|
"anyOf": [
|
|
118
114
|
{
|
|
119
115
|
"type": "number",
|
|
@@ -125,7 +121,6 @@
|
|
|
125
121
|
]
|
|
126
122
|
},
|
|
127
123
|
"maxELU": {
|
|
128
|
-
"default": 0.99,
|
|
129
124
|
"anyOf": [
|
|
130
125
|
{
|
|
131
126
|
"type": "number",
|
|
@@ -138,7 +133,6 @@
|
|
|
138
133
|
]
|
|
139
134
|
},
|
|
140
135
|
"maxHeapUsed": {
|
|
141
|
-
"default": 0.99,
|
|
142
136
|
"anyOf": [
|
|
143
137
|
{
|
|
144
138
|
"type": "number",
|
|
@@ -151,7 +145,6 @@
|
|
|
151
145
|
]
|
|
152
146
|
},
|
|
153
147
|
"maxHeapTotal": {
|
|
154
|
-
"default": 4294967296,
|
|
155
148
|
"anyOf": [
|
|
156
149
|
{
|
|
157
150
|
"type": "number",
|
|
@@ -249,7 +242,6 @@
|
|
|
249
242
|
"type": "object",
|
|
250
243
|
"properties": {
|
|
251
244
|
"enabled": {
|
|
252
|
-
"default": true,
|
|
253
245
|
"anyOf": [
|
|
254
246
|
{
|
|
255
247
|
"type": "boolean"
|
|
@@ -260,7 +252,6 @@
|
|
|
260
252
|
]
|
|
261
253
|
},
|
|
262
254
|
"interval": {
|
|
263
|
-
"default": 30000,
|
|
264
255
|
"anyOf": [
|
|
265
256
|
{
|
|
266
257
|
"type": "number",
|
|
@@ -272,7 +263,6 @@
|
|
|
272
263
|
]
|
|
273
264
|
},
|
|
274
265
|
"gracePeriod": {
|
|
275
|
-
"default": 30000,
|
|
276
266
|
"anyOf": [
|
|
277
267
|
{
|
|
278
268
|
"type": "number",
|
|
@@ -284,7 +274,6 @@
|
|
|
284
274
|
]
|
|
285
275
|
},
|
|
286
276
|
"maxUnhealthyChecks": {
|
|
287
|
-
"default": 10,
|
|
288
277
|
"anyOf": [
|
|
289
278
|
{
|
|
290
279
|
"type": "number",
|
|
@@ -296,7 +285,6 @@
|
|
|
296
285
|
]
|
|
297
286
|
},
|
|
298
287
|
"maxELU": {
|
|
299
|
-
"default": 0.99,
|
|
300
288
|
"anyOf": [
|
|
301
289
|
{
|
|
302
290
|
"type": "number",
|
|
@@ -309,7 +297,6 @@
|
|
|
309
297
|
]
|
|
310
298
|
},
|
|
311
299
|
"maxHeapUsed": {
|
|
312
|
-
"default": 0.99,
|
|
313
300
|
"anyOf": [
|
|
314
301
|
{
|
|
315
302
|
"type": "number",
|
|
@@ -322,7 +309,6 @@
|
|
|
322
309
|
]
|
|
323
310
|
},
|
|
324
311
|
"maxHeapTotal": {
|
|
325
|
-
"default": 4294967296,
|
|
326
312
|
"anyOf": [
|
|
327
313
|
{
|
|
328
314
|
"type": "number",
|
|
@@ -485,7 +471,6 @@
|
|
|
485
471
|
"type": "object",
|
|
486
472
|
"properties": {
|
|
487
473
|
"enabled": {
|
|
488
|
-
"default": true,
|
|
489
474
|
"anyOf": [
|
|
490
475
|
{
|
|
491
476
|
"type": "boolean"
|
|
@@ -496,7 +481,6 @@
|
|
|
496
481
|
]
|
|
497
482
|
},
|
|
498
483
|
"interval": {
|
|
499
|
-
"default": 30000,
|
|
500
484
|
"anyOf": [
|
|
501
485
|
{
|
|
502
486
|
"type": "number",
|
|
@@ -508,7 +492,6 @@
|
|
|
508
492
|
]
|
|
509
493
|
},
|
|
510
494
|
"gracePeriod": {
|
|
511
|
-
"default": 30000,
|
|
512
495
|
"anyOf": [
|
|
513
496
|
{
|
|
514
497
|
"type": "number",
|
|
@@ -520,7 +503,6 @@
|
|
|
520
503
|
]
|
|
521
504
|
},
|
|
522
505
|
"maxUnhealthyChecks": {
|
|
523
|
-
"default": 10,
|
|
524
506
|
"anyOf": [
|
|
525
507
|
{
|
|
526
508
|
"type": "number",
|
|
@@ -532,7 +514,6 @@
|
|
|
532
514
|
]
|
|
533
515
|
},
|
|
534
516
|
"maxELU": {
|
|
535
|
-
"default": 0.99,
|
|
536
517
|
"anyOf": [
|
|
537
518
|
{
|
|
538
519
|
"type": "number",
|
|
@@ -545,7 +526,6 @@
|
|
|
545
526
|
]
|
|
546
527
|
},
|
|
547
528
|
"maxHeapUsed": {
|
|
548
|
-
"default": 0.99,
|
|
549
529
|
"anyOf": [
|
|
550
530
|
{
|
|
551
531
|
"type": "number",
|
|
@@ -558,7 +538,6 @@
|
|
|
558
538
|
]
|
|
559
539
|
},
|
|
560
540
|
"maxHeapTotal": {
|
|
561
|
-
"default": 4294967296,
|
|
562
541
|
"anyOf": [
|
|
563
542
|
{
|
|
564
543
|
"type": "number",
|
|
@@ -1137,6 +1116,16 @@
|
|
|
1137
1116
|
}
|
|
1138
1117
|
]
|
|
1139
1118
|
},
|
|
1119
|
+
"enabled": {
|
|
1120
|
+
"anyOf": [
|
|
1121
|
+
{
|
|
1122
|
+
"type": "boolean"
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
"type": "string"
|
|
1126
|
+
}
|
|
1127
|
+
]
|
|
1128
|
+
},
|
|
1140
1129
|
"hostname": {
|
|
1141
1130
|
"type": "string"
|
|
1142
1131
|
},
|