@platformatic/runtime 3.19.0 → 3.21.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 -0
- package/index.d.ts +1 -1
- package/index.js +4 -1
- package/lib/runtime.js +26 -24
- package/lib/worker/symbols.js +1 -1
- package/lib/{dynamic-workers-scaler.js → worker-scaler.js} +3 -3
- package/package.json +15 -15
- package/schema.json +65 -11
package/config.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type PlatformaticRuntimeConfig = {
|
|
|
39
39
|
maxHeapUsed?: number | string;
|
|
40
40
|
maxHeapTotal?: number | string;
|
|
41
41
|
maxYoungGeneration?: number | string;
|
|
42
|
+
codeRangeSize?: number | string;
|
|
42
43
|
};
|
|
43
44
|
dependencies?: string[];
|
|
44
45
|
arguments?: string[];
|
|
@@ -200,6 +201,7 @@ export type PlatformaticRuntimeConfig = {
|
|
|
200
201
|
maxHeapUsed?: number | string;
|
|
201
202
|
maxHeapTotal?: number | string;
|
|
202
203
|
maxYoungGeneration?: number | string;
|
|
204
|
+
codeRangeSize?: number | string;
|
|
203
205
|
};
|
|
204
206
|
undici?: {
|
|
205
207
|
agentOptions?: {
|
package/index.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export module symbols {
|
|
|
57
57
|
export declare const kHealthCheckTimer: unique symbol
|
|
58
58
|
export declare const kHealthMetricsTimer: unique symbol
|
|
59
59
|
export declare const kLastHealthCheckELU: unique symbol
|
|
60
|
-
export declare const
|
|
60
|
+
export declare const kLastWorkerScalerELU: unique symbol
|
|
61
61
|
export declare const kWorkerStatus: unique symbol
|
|
62
62
|
export declare const kWorkerHealthSignals: unique symbol
|
|
63
63
|
export declare const kStderrMarker: string
|
package/index.js
CHANGED
|
@@ -63,7 +63,10 @@ export async function loadConfiguration (configOrRoot, sourceOrConfig, context)
|
|
|
63
63
|
const { root, source } = await resolve(configOrRoot, sourceOrConfig, 'runtime')
|
|
64
64
|
|
|
65
65
|
// First of all, load the configuration without any validation
|
|
66
|
-
const config = await utilsLoadConfiguration(source
|
|
66
|
+
const config = await utilsLoadConfiguration(source, null, {
|
|
67
|
+
root,
|
|
68
|
+
envFile: context?.envFile
|
|
69
|
+
})
|
|
67
70
|
const mod = extractModuleFromSchemaUrl(config)
|
|
68
71
|
if (mod?.module !== '@platformatic/runtime') {
|
|
69
72
|
return wrapInRuntimeConfig(config, context)
|
package/lib/runtime.js
CHANGED
|
@@ -24,7 +24,6 @@ import SonicBoom from 'sonic-boom'
|
|
|
24
24
|
import { Agent, request, interceptors as undiciInterceptors } from 'undici'
|
|
25
25
|
import { createThreadInterceptor } from 'undici-thread-interceptor'
|
|
26
26
|
import { pprofCapturePreloadPath } from './config.js'
|
|
27
|
-
import { DynamicWorkersScaler } from './dynamic-workers-scaler.js'
|
|
28
27
|
import {
|
|
29
28
|
ApplicationAlreadyStartedError,
|
|
30
29
|
ApplicationNotFoundError,
|
|
@@ -45,6 +44,7 @@ import { startPrometheusServer } from './prom-server.js'
|
|
|
45
44
|
import { startScheduler } from './scheduler.js'
|
|
46
45
|
import { createSharedStore } from './shared-http-cache.js'
|
|
47
46
|
import { version } from './version.js'
|
|
47
|
+
import { DynamicWorkersScaler } from './worker-scaler.js'
|
|
48
48
|
import { HealthSignalsQueue } from './worker/health-signals.js'
|
|
49
49
|
import { sendMultipleViaITC, sendViaITC, waitEventFromITC } from './worker/itc.js'
|
|
50
50
|
import { RoundRobinMap } from './worker/round-robin-map.js'
|
|
@@ -206,7 +206,7 @@ export class Runtime extends EventEmitter {
|
|
|
206
206
|
if (this.#config.workers.dynamic) {
|
|
207
207
|
if (this.#config.workers.dynamic === false) {
|
|
208
208
|
this.logger.warn(
|
|
209
|
-
`
|
|
209
|
+
`Worker scaler disabled because the "workers" configuration is set to ${this.#config.workers.static}.`
|
|
210
210
|
)
|
|
211
211
|
} else {
|
|
212
212
|
this.#dynamicWorkersScaler = new DynamicWorkersScaler(this, this.#config.workers)
|
|
@@ -698,7 +698,9 @@ export class Runtime extends EventEmitter {
|
|
|
698
698
|
|
|
699
699
|
// TODO: Remove in next major version
|
|
700
700
|
startCollectingMetrics () {
|
|
701
|
-
this.logger.warn(
|
|
701
|
+
this.logger.warn(
|
|
702
|
+
'startCollectingMetrics() is deprecated and no longer collects metrics. Metrics are now polled on-demand by the management API.'
|
|
703
|
+
)
|
|
702
704
|
}
|
|
703
705
|
|
|
704
706
|
// TODO: Remove in next major version
|
|
@@ -1196,6 +1198,7 @@ export class Runtime extends EventEmitter {
|
|
|
1196
1198
|
|
|
1197
1199
|
const { entrypoint, localUrl, config, path } = application[kConfig]
|
|
1198
1200
|
|
|
1201
|
+
const sourceMaps = application[kConfig].sourceMaps ?? this.#config.sourceMaps
|
|
1199
1202
|
const status = await sendViaITC(application, 'getStatus')
|
|
1200
1203
|
const { type, version, dependencies } = await sendViaITC(application, 'getApplicationInfo')
|
|
1201
1204
|
|
|
@@ -1208,7 +1211,8 @@ export class Runtime extends EventEmitter {
|
|
|
1208
1211
|
dependencies,
|
|
1209
1212
|
version,
|
|
1210
1213
|
localUrl,
|
|
1211
|
-
entrypoint
|
|
1214
|
+
entrypoint,
|
|
1215
|
+
sourceMaps
|
|
1212
1216
|
}
|
|
1213
1217
|
|
|
1214
1218
|
if (this.#isProduction) {
|
|
@@ -1449,26 +1453,20 @@ export class Runtime extends EventEmitter {
|
|
|
1449
1453
|
workerEnv.NODE_OPTIONS = `${originalNodeOptions} ${applicationConfig.nodeOptions}`.trim()
|
|
1450
1454
|
}
|
|
1451
1455
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
: health.maxYoungGeneration
|
|
1456
|
+
const maxHeapTotal =
|
|
1457
|
+
typeof health.maxHeapTotal === 'string' ? parseMemorySize(health.maxHeapTotal) : health.maxHeapTotal
|
|
1458
|
+
const maxYoungGeneration =
|
|
1459
|
+
typeof health.maxYoungGeneration === 'string'
|
|
1460
|
+
? parseMemorySize(health.maxYoungGeneration)
|
|
1461
|
+
: health.maxYoungGeneration
|
|
1462
|
+
const codeRangeSize =
|
|
1463
|
+
typeof health.codeRangeSize === 'string' ? parseMemorySize(health.codeRangeSize) : health.codeRangeSize
|
|
1461
1464
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
maxOldGenerationSizeMb,
|
|
1468
|
-
maxYoungGenerationSizeMb
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1465
|
+
const maxOldGenerationSizeMb = Math.floor(
|
|
1466
|
+
(maxYoungGeneration > 0 ? maxHeapTotal - maxYoungGeneration : maxHeapTotal) / (1024 * 1024)
|
|
1467
|
+
)
|
|
1468
|
+
const maxYoungGenerationSizeMb = maxYoungGeneration ? Math.floor(maxYoungGeneration / (1024 * 1024)) : undefined
|
|
1469
|
+
const codeRangeSizeMb = codeRangeSize ? Math.floor(codeRangeSize / (1024 * 1024)) : undefined
|
|
1472
1470
|
|
|
1473
1471
|
const worker = new Worker(kWorkerFile, {
|
|
1474
1472
|
workerData: {
|
|
@@ -1492,7 +1490,11 @@ export class Runtime extends EventEmitter {
|
|
|
1492
1490
|
argv: applicationConfig.arguments,
|
|
1493
1491
|
execArgv,
|
|
1494
1492
|
env: workerEnv,
|
|
1495
|
-
resourceLimits
|
|
1493
|
+
resourceLimits: {
|
|
1494
|
+
maxOldGenerationSizeMb,
|
|
1495
|
+
maxYoungGenerationSizeMb,
|
|
1496
|
+
codeRangeSizeMb
|
|
1497
|
+
},
|
|
1496
1498
|
stdout: true,
|
|
1497
1499
|
stderr: true
|
|
1498
1500
|
})
|
package/lib/worker/symbols.js
CHANGED
|
@@ -10,7 +10,7 @@ export const kWorkerHealthSignals = Symbol.for('plt.runtime.worker.healthSignals
|
|
|
10
10
|
export const kWorkerStartTime = Symbol.for('plt.runtime.worker.startTime')
|
|
11
11
|
export const kInterceptors = Symbol.for('plt.runtime.worker.interceptors')
|
|
12
12
|
export const kLastHealthCheckELU = Symbol.for('plt.runtime.worker.lastHealthCheckELU')
|
|
13
|
-
export const
|
|
13
|
+
export const kLastWorkerScalerELU = Symbol.for('plt.runtime.worker.lastWorkerScalerELU')
|
|
14
14
|
|
|
15
15
|
// This string marker should be safe to use since it belongs to Unicode private area
|
|
16
16
|
export const kStderrMarker = '\ue002'
|
|
@@ -2,7 +2,7 @@ import { features } from '@platformatic/foundation'
|
|
|
2
2
|
import { availableParallelism } from 'node:os'
|
|
3
3
|
import { getMemoryInfo } from './metrics.js'
|
|
4
4
|
import { ScalingAlgorithm, scaleUpELUThreshold } from './scaling-algorithm.js'
|
|
5
|
-
import { kApplicationId, kId,
|
|
5
|
+
import { kApplicationId, kId, kLastWorkerScalerELU, kWorkerStartTime, kWorkerStatus } from './worker/symbols.js'
|
|
6
6
|
|
|
7
7
|
const healthCheckInterval = 1000
|
|
8
8
|
export const kOriginalWorkers = Symbol('plt.runtime.application.dynamicWorkersScalerOriginalWorkers')
|
|
@@ -135,13 +135,13 @@ export class DynamicWorkersScaler {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
try {
|
|
138
|
-
const health = await this.#runtime.getWorkerHealth(worker, { previousELU: worker[
|
|
138
|
+
const health = await this.#runtime.getWorkerHealth(worker, { previousELU: worker[kLastWorkerScalerELU] })
|
|
139
139
|
|
|
140
140
|
if (!health) {
|
|
141
141
|
continue
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
worker[
|
|
144
|
+
worker[kLastWorkerScalerELU] = health.currentELU
|
|
145
145
|
|
|
146
146
|
this.#algorithm.addWorkerHealthInfo({
|
|
147
147
|
workerId: worker[kId],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"typescript": "^5.5.4",
|
|
36
36
|
"undici-oidc-interceptor": "^0.5.0",
|
|
37
37
|
"why-is-node-running": "^2.2.2",
|
|
38
|
-
"@platformatic/composer": "3.
|
|
39
|
-
"@platformatic/db": "3.
|
|
40
|
-
"@platformatic/gateway": "3.
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/sql-mapper": "3.
|
|
44
|
-
"@platformatic/
|
|
45
|
-
"@platformatic/
|
|
38
|
+
"@platformatic/composer": "3.21.0",
|
|
39
|
+
"@platformatic/db": "3.21.0",
|
|
40
|
+
"@platformatic/gateway": "3.21.0",
|
|
41
|
+
"@platformatic/sql-graphql": "3.21.0",
|
|
42
|
+
"@platformatic/node": "3.21.0",
|
|
43
|
+
"@platformatic/sql-mapper": "3.21.0",
|
|
44
|
+
"@platformatic/wattpm-pprof-capture": "3.21.0",
|
|
45
|
+
"@platformatic/service": "3.21.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"undici": "^7.0.0",
|
|
72
72
|
"undici-thread-interceptor": "^0.15.0",
|
|
73
73
|
"ws": "^8.16.0",
|
|
74
|
-
"@platformatic/basic": "3.
|
|
75
|
-
"@platformatic/generators": "3.
|
|
76
|
-
"@platformatic/foundation": "3.
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/metrics": "3.
|
|
74
|
+
"@platformatic/basic": "3.21.0",
|
|
75
|
+
"@platformatic/generators": "3.21.0",
|
|
76
|
+
"@platformatic/foundation": "3.21.0",
|
|
77
|
+
"@platformatic/itc": "3.21.0",
|
|
78
|
+
"@platformatic/telemetry": "3.21.0",
|
|
79
|
+
"@platformatic/metrics": "3.21.0"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.21.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Runtime Config",
|
|
5
5
|
"type": "object",
|
|
@@ -187,6 +187,17 @@
|
|
|
187
187
|
"type": "string"
|
|
188
188
|
}
|
|
189
189
|
]
|
|
190
|
+
},
|
|
191
|
+
"codeRangeSize": {
|
|
192
|
+
"anyOf": [
|
|
193
|
+
{
|
|
194
|
+
"type": "number",
|
|
195
|
+
"minimum": 0
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "string"
|
|
199
|
+
}
|
|
200
|
+
]
|
|
190
201
|
}
|
|
191
202
|
},
|
|
192
203
|
"additionalProperties": false
|
|
@@ -214,8 +225,7 @@
|
|
|
214
225
|
"type": "string"
|
|
215
226
|
},
|
|
216
227
|
"sourceMaps": {
|
|
217
|
-
"type": "boolean"
|
|
218
|
-
"default": false
|
|
228
|
+
"type": "boolean"
|
|
219
229
|
},
|
|
220
230
|
"packageManager": {
|
|
221
231
|
"type": "string",
|
|
@@ -469,6 +479,17 @@
|
|
|
469
479
|
"type": "string"
|
|
470
480
|
}
|
|
471
481
|
]
|
|
482
|
+
},
|
|
483
|
+
"codeRangeSize": {
|
|
484
|
+
"anyOf": [
|
|
485
|
+
{
|
|
486
|
+
"type": "number",
|
|
487
|
+
"minimum": 0
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
"type": "string"
|
|
491
|
+
}
|
|
492
|
+
]
|
|
472
493
|
}
|
|
473
494
|
},
|
|
474
495
|
"additionalProperties": false
|
|
@@ -496,8 +517,7 @@
|
|
|
496
517
|
"type": "string"
|
|
497
518
|
},
|
|
498
519
|
"sourceMaps": {
|
|
499
|
-
"type": "boolean"
|
|
500
|
-
"default": false
|
|
520
|
+
"type": "boolean"
|
|
501
521
|
},
|
|
502
522
|
"packageManager": {
|
|
503
523
|
"type": "string",
|
|
@@ -749,6 +769,17 @@
|
|
|
749
769
|
"type": "string"
|
|
750
770
|
}
|
|
751
771
|
]
|
|
772
|
+
},
|
|
773
|
+
"codeRangeSize": {
|
|
774
|
+
"anyOf": [
|
|
775
|
+
{
|
|
776
|
+
"type": "number",
|
|
777
|
+
"minimum": 0
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
"type": "string"
|
|
781
|
+
}
|
|
782
|
+
]
|
|
752
783
|
}
|
|
753
784
|
},
|
|
754
785
|
"additionalProperties": false
|
|
@@ -776,8 +807,7 @@
|
|
|
776
807
|
"type": "string"
|
|
777
808
|
},
|
|
778
809
|
"sourceMaps": {
|
|
779
|
-
"type": "boolean"
|
|
780
|
-
"default": false
|
|
810
|
+
"type": "boolean"
|
|
781
811
|
},
|
|
782
812
|
"packageManager": {
|
|
783
813
|
"type": "string",
|
|
@@ -1029,6 +1059,17 @@
|
|
|
1029
1059
|
"type": "string"
|
|
1030
1060
|
}
|
|
1031
1061
|
]
|
|
1062
|
+
},
|
|
1063
|
+
"codeRangeSize": {
|
|
1064
|
+
"anyOf": [
|
|
1065
|
+
{
|
|
1066
|
+
"type": "number",
|
|
1067
|
+
"minimum": 0
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
"type": "string"
|
|
1071
|
+
}
|
|
1072
|
+
]
|
|
1032
1073
|
}
|
|
1033
1074
|
},
|
|
1034
1075
|
"additionalProperties": false
|
|
@@ -1056,8 +1097,7 @@
|
|
|
1056
1097
|
"type": "string"
|
|
1057
1098
|
},
|
|
1058
1099
|
"sourceMaps": {
|
|
1059
|
-
"type": "boolean"
|
|
1060
|
-
"default": false
|
|
1100
|
+
"type": "boolean"
|
|
1061
1101
|
},
|
|
1062
1102
|
"packageManager": {
|
|
1063
1103
|
"type": "string",
|
|
@@ -1626,7 +1666,8 @@
|
|
|
1626
1666
|
{
|
|
1627
1667
|
"type": "string"
|
|
1628
1668
|
}
|
|
1629
|
-
]
|
|
1669
|
+
],
|
|
1670
|
+
"default": 4294967296
|
|
1630
1671
|
},
|
|
1631
1672
|
"maxYoungGeneration": {
|
|
1632
1673
|
"anyOf": [
|
|
@@ -1637,7 +1678,20 @@
|
|
|
1637
1678
|
{
|
|
1638
1679
|
"type": "string"
|
|
1639
1680
|
}
|
|
1640
|
-
]
|
|
1681
|
+
],
|
|
1682
|
+
"default": 134217728
|
|
1683
|
+
},
|
|
1684
|
+
"codeRangeSize": {
|
|
1685
|
+
"anyOf": [
|
|
1686
|
+
{
|
|
1687
|
+
"type": "number",
|
|
1688
|
+
"minimum": 0
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
"type": "string"
|
|
1692
|
+
}
|
|
1693
|
+
],
|
|
1694
|
+
"default": 268435456
|
|
1641
1695
|
}
|
|
1642
1696
|
},
|
|
1643
1697
|
"additionalProperties": false
|