@platformatic/runtime 3.24.0-alpha0 → 3.24.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 +4 -0
- package/lib/config.js +26 -8
- package/lib/generator.js +1 -6
- package/lib/management-api.js +1 -1
- package/lib/runtime.js +3 -4
- package/package.json +15 -15
- package/schema.json +5 -1
package/config.d.ts
CHANGED
|
@@ -155,6 +155,10 @@ export type PlatformaticRuntimeConfig = {
|
|
|
155
155
|
server?: {
|
|
156
156
|
hostname?: string;
|
|
157
157
|
port?: number | string;
|
|
158
|
+
/**
|
|
159
|
+
* The maximum length of the queue of pending connections
|
|
160
|
+
*/
|
|
161
|
+
backlog?: number;
|
|
158
162
|
http2?: boolean;
|
|
159
163
|
https?: {
|
|
160
164
|
allowHTTP1?: boolean;
|
package/lib/config.js
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { readdir, readFile } from 'node:fs/promises'
|
|
13
13
|
import { createRequire } from 'node:module'
|
|
14
14
|
import { isAbsolute, join, resolve as resolvePath } from 'node:path'
|
|
15
|
+
|
|
15
16
|
import {
|
|
16
17
|
InspectAndInspectBrkError,
|
|
17
18
|
InspectorHostError,
|
|
@@ -45,7 +46,7 @@ function raiseInvalidWorkersError (location, received, hint) {
|
|
|
45
46
|
throw new InvalidArgumentError(`${location} workers must be a positive integer; received "${received}"${extra}`)
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function parseWorkers (config, prefix, defaultWorkers = 1) {
|
|
49
|
+
function parseWorkers (config, prefix, defaultWorkers = { static: 1, dynamic: false }) {
|
|
49
50
|
if (typeof config.workers !== 'undefined') {
|
|
50
51
|
// Number
|
|
51
52
|
if (typeof config.workers !== 'object') {
|
|
@@ -75,9 +76,26 @@ function parseWorkers (config, prefix, defaultWorkers = 1) {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
// No value, inherit from runtime
|
|
79
79
|
} else {
|
|
80
|
-
config.workers = {
|
|
80
|
+
config.workers = {}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Fill missing values from defaults
|
|
84
|
+
for (const key of ['minimum', 'maximum', 'static', 'dynamic']) {
|
|
85
|
+
if (typeof config.workers[key] === 'undefined' && typeof defaultWorkers[key] !== 'undefined') {
|
|
86
|
+
config.workers[key] = defaultWorkers[key]
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Additional validations
|
|
91
|
+
if (config.workers.maximum < config.workers.minimum) {
|
|
92
|
+
const t = config.workers.minimum
|
|
93
|
+
config.workers.minimum = config.workers.maximum
|
|
94
|
+
config.workers.maximum = t
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (typeof config.workers.static === 'undefined') {
|
|
98
|
+
config.workers.static = config.workers.minimum
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
101
|
|
|
@@ -271,10 +289,10 @@ export async function transform (config, _, context) {
|
|
|
271
289
|
// TODO: Remove in the next major version
|
|
272
290
|
if (config.verticalScaler) {
|
|
273
291
|
config.workers ??= {}
|
|
274
|
-
config.workers.dynamic ??= config.verticalScaler.enabled
|
|
275
|
-
config.workers.minimum ??= config.verticalScaler.minWorkers
|
|
276
|
-
config.workers.maximum ??= config.verticalScaler.maxWorkers
|
|
277
292
|
config.workers.total ??= config.verticalScaler.maxTotalWorkers
|
|
293
|
+
config.workers.dynamic ??= config.verticalScaler.enabled
|
|
294
|
+
config.workers.minimum ??= config.verticalScaler.minWorkers ?? 1
|
|
295
|
+
config.workers.maximum ??= config.verticalScaler.maxWorkers ?? config.verticalScaler.maxTotalWorkers ?? 1
|
|
278
296
|
config.workers.maxMemory ??= config.verticalScaler.maxTotalMemory
|
|
279
297
|
|
|
280
298
|
if (typeof config.workers.cooldown === 'undefined' && typeof config.verticalScaler.cooldownSec === 'number') {
|
|
@@ -330,8 +348,8 @@ export async function transform (config, _, context) {
|
|
|
330
348
|
let hasValidEntrypoint = false
|
|
331
349
|
|
|
332
350
|
// Root-level workers
|
|
333
|
-
parseWorkers(config, 'Runtime')
|
|
334
|
-
const defaultWorkers = config.workers
|
|
351
|
+
parseWorkers(config, 'Runtime', { static: 1, dynamic: false })
|
|
352
|
+
const defaultWorkers = config.workers
|
|
335
353
|
|
|
336
354
|
for (let i = 0; i < applications.length; ++i) {
|
|
337
355
|
const application = await prepareApplication(config, applications[i], defaultWorkers)
|
package/lib/generator.js
CHANGED
|
@@ -102,12 +102,7 @@ export class RuntimeGenerator extends BaseGenerator {
|
|
|
102
102
|
build: this.config.buildCommand ?? 'wattpm build',
|
|
103
103
|
start: this.config.startCommand ?? 'wattpm start'
|
|
104
104
|
},
|
|
105
|
-
devDependencies: {
|
|
106
|
-
fastify: `^${this.fastifyVersion}`
|
|
107
|
-
},
|
|
108
105
|
dependencies: {
|
|
109
|
-
'@platformatic/runtime': `^${this.platformaticVersion}`,
|
|
110
|
-
platformatic: `^${this.platformaticVersion}`,
|
|
111
106
|
wattpm: `^${this.platformaticVersion}`,
|
|
112
107
|
...this.config.dependencies
|
|
113
108
|
},
|
|
@@ -189,7 +184,7 @@ export class RuntimeGenerator extends BaseGenerator {
|
|
|
189
184
|
|
|
190
185
|
async _getConfigFileContents () {
|
|
191
186
|
const config = {
|
|
192
|
-
$schema: `https://schemas.platformatic.dev
|
|
187
|
+
$schema: `https://schemas.platformatic.dev/wattpm/${this.platformaticVersion}.json`,
|
|
193
188
|
entrypoint: this.entryPoint.name,
|
|
194
189
|
watch: true,
|
|
195
190
|
autoload: {
|
package/lib/management-api.js
CHANGED
|
@@ -104,7 +104,7 @@ export async function managementApiPlugin (app, opts) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
for (let i = 0; i < applications.length; i++) {
|
|
107
|
-
applications[i] = await prepareApplication(config, applications[i])
|
|
107
|
+
applications[i] = await prepareApplication(config, applications[i], config.workers)
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const created = await runtime.addApplications(applications, request.query.start !== 'false')
|
package/lib/runtime.js
CHANGED
|
@@ -450,8 +450,7 @@ export class Runtime extends EventEmitter {
|
|
|
450
450
|
this.logger.warn(
|
|
451
451
|
`"${application.id}" is set as the entrypoint, but reusePort is not available in your OS; setting workers to 1 instead of ${workers.static}`
|
|
452
452
|
)
|
|
453
|
-
workers
|
|
454
|
-
workers.minimum = 1
|
|
453
|
+
application.workers = { dynamic: false, static: 1 }
|
|
455
454
|
}
|
|
456
455
|
|
|
457
456
|
this.#applications.set(application.id, application)
|
|
@@ -1580,8 +1579,8 @@ export class Runtime extends EventEmitter {
|
|
|
1580
1579
|
worker[kITC].on('event', ({ event, payload }) => {
|
|
1581
1580
|
event = `application:worker:event:${event}`
|
|
1582
1581
|
|
|
1583
|
-
this.emit(event, ...payload)
|
|
1584
|
-
this.logger.trace({ event, payload }, 'Runtime event')
|
|
1582
|
+
this.emit(event, ...payload, workerId, applicationId, index)
|
|
1583
|
+
this.logger.trace({ event, payload, id: workerId, application: applicationId, worker: index }, 'Runtime event')
|
|
1585
1584
|
})
|
|
1586
1585
|
|
|
1587
1586
|
worker[kITC].on('request:restart', async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "3.24.0
|
|
3
|
+
"version": "3.24.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.24.0
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/sql-
|
|
44
|
-
"@platformatic/
|
|
45
|
-
"@platformatic/
|
|
38
|
+
"@platformatic/composer": "3.24.0",
|
|
39
|
+
"@platformatic/db": "3.24.0",
|
|
40
|
+
"@platformatic/gateway": "3.24.0",
|
|
41
|
+
"@platformatic/service": "3.24.0",
|
|
42
|
+
"@platformatic/node": "3.24.0",
|
|
43
|
+
"@platformatic/sql-graphql": "3.24.0",
|
|
44
|
+
"@platformatic/sql-mapper": "3.24.0",
|
|
45
|
+
"@platformatic/wattpm-pprof-capture": "3.24.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.24.0
|
|
75
|
-
"@platformatic/
|
|
76
|
-
"@platformatic/
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/
|
|
74
|
+
"@platformatic/basic": "3.24.0",
|
|
75
|
+
"@platformatic/foundation": "3.24.0",
|
|
76
|
+
"@platformatic/generators": "3.24.0",
|
|
77
|
+
"@platformatic/itc": "3.24.0",
|
|
78
|
+
"@platformatic/telemetry": "3.24.0",
|
|
79
|
+
"@platformatic/metrics": "3.24.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.24.0
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.24.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Runtime Config",
|
|
5
5
|
"type": "object",
|
|
@@ -1421,6 +1421,10 @@
|
|
|
1421
1421
|
}
|
|
1422
1422
|
]
|
|
1423
1423
|
},
|
|
1424
|
+
"backlog": {
|
|
1425
|
+
"type": "integer",
|
|
1426
|
+
"description": "The maximum length of the queue of pending connections"
|
|
1427
|
+
},
|
|
1424
1428
|
"http2": {
|
|
1425
1429
|
"type": "boolean"
|
|
1426
1430
|
},
|