@platformatic/basic 3.31.0 → 3.32.0-alpha.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 +3 -25
- package/lib/capability.js +3 -6
- package/lib/worker/child-process.js +4 -57
- package/package.json +5 -5
- package/schema.json +36 -67
package/config.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export interface PlatformaticBasicConfig {
|
|
|
31
31
|
};
|
|
32
32
|
workersRestartDelay?: number | string;
|
|
33
33
|
logger?: {
|
|
34
|
-
level
|
|
34
|
+
level: (
|
|
35
35
|
| ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
|
|
36
36
|
| {
|
|
37
37
|
[k: string]: unknown;
|
|
@@ -134,6 +134,7 @@ export interface PlatformaticBasicConfig {
|
|
|
134
134
|
maxHeapTotal?: number | string;
|
|
135
135
|
maxYoungGeneration?: number | string;
|
|
136
136
|
codeRangeSize?: number | string;
|
|
137
|
+
noHeapCheck?: boolean | string;
|
|
137
138
|
};
|
|
138
139
|
undici?: {
|
|
139
140
|
agentOptions?: {
|
|
@@ -414,18 +415,6 @@ export interface PlatformaticBasicConfig {
|
|
|
414
415
|
[k: string]: string | [string, ...string[]];
|
|
415
416
|
};
|
|
416
417
|
};
|
|
417
|
-
compileCache?:
|
|
418
|
-
| boolean
|
|
419
|
-
| {
|
|
420
|
-
/**
|
|
421
|
-
* Enable Node.js module compile cache for faster startup
|
|
422
|
-
*/
|
|
423
|
-
enabled?: boolean;
|
|
424
|
-
/**
|
|
425
|
-
* Directory to store compile cache. Defaults to .plt/compile-cache in app root
|
|
426
|
-
*/
|
|
427
|
-
directory?: string;
|
|
428
|
-
};
|
|
429
418
|
application?: {
|
|
430
419
|
reuseTcpPorts?: boolean;
|
|
431
420
|
workers?:
|
|
@@ -449,6 +438,7 @@ export interface PlatformaticBasicConfig {
|
|
|
449
438
|
maxHeapTotal?: number | string;
|
|
450
439
|
maxYoungGeneration?: number | string;
|
|
451
440
|
codeRangeSize?: number | string;
|
|
441
|
+
noHeapCheck?: boolean | string;
|
|
452
442
|
};
|
|
453
443
|
arguments?: string[];
|
|
454
444
|
env?: {
|
|
@@ -484,18 +474,6 @@ export interface PlatformaticBasicConfig {
|
|
|
484
474
|
)[];
|
|
485
475
|
[k: string]: unknown;
|
|
486
476
|
};
|
|
487
|
-
compileCache?:
|
|
488
|
-
| boolean
|
|
489
|
-
| {
|
|
490
|
-
/**
|
|
491
|
-
* Enable Node.js module compile cache for faster startup
|
|
492
|
-
*/
|
|
493
|
-
enabled?: boolean;
|
|
494
|
-
/**
|
|
495
|
-
* Directory to store compile cache. Defaults to .plt/compile-cache in app root
|
|
496
|
-
*/
|
|
497
|
-
directory?: string;
|
|
498
|
-
};
|
|
499
477
|
};
|
|
500
478
|
};
|
|
501
479
|
[k: string]: unknown;
|
package/lib/capability.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
kMetadata,
|
|
8
8
|
kTimeout
|
|
9
9
|
} from '@platformatic/foundation'
|
|
10
|
-
import { clearRegistry, client,
|
|
10
|
+
import { clearRegistry, client, collectMetrics, ensureMetricsGroup, setupOtlpExporter } from '@platformatic/metrics'
|
|
11
11
|
import { parseCommandString } from 'execa'
|
|
12
12
|
import { spawn } from 'node:child_process'
|
|
13
13
|
import { tracingChannel } from 'node:diagnostics_channel'
|
|
@@ -578,8 +578,7 @@ export class BaseCapability extends EventEmitter {
|
|
|
578
578
|
backlog: this.serverConfig.backlog
|
|
579
579
|
}
|
|
580
580
|
: {},
|
|
581
|
-
telemetryConfig: this.telemetryConfig
|
|
582
|
-
compileCache: this.config.compileCache ?? this.runtimeConfig?.compileCache
|
|
581
|
+
telemetryConfig: this.telemetryConfig
|
|
583
582
|
}
|
|
584
583
|
}
|
|
585
584
|
|
|
@@ -740,9 +739,7 @@ export class BaseCapability extends EventEmitter {
|
|
|
740
739
|
return
|
|
741
740
|
}
|
|
742
741
|
|
|
743
|
-
|
|
744
|
-
// by the main runtime thread and duplicated with worker labels
|
|
745
|
-
await collectThreadMetrics(this.applicationId, this.workerId, metricsConfig, this.metricsRegistry)
|
|
742
|
+
await collectMetrics(this.applicationId, this.workerId, metricsConfig, this.metricsRegistry)
|
|
746
743
|
}
|
|
747
744
|
|
|
748
745
|
#setHttpCacheMetrics () {
|
|
@@ -5,15 +5,14 @@ import {
|
|
|
5
5
|
ensureLoggableError
|
|
6
6
|
} from '@platformatic/foundation'
|
|
7
7
|
import { ITC } from '@platformatic/itc/lib/index.js'
|
|
8
|
-
import { clearRegistry, client,
|
|
8
|
+
import { clearRegistry, client, collectMetrics } from '@platformatic/metrics'
|
|
9
9
|
import diagnosticChannel, { tracingChannel } from 'node:diagnostics_channel'
|
|
10
10
|
import { EventEmitter, once } from 'node:events'
|
|
11
11
|
import { readFile } from 'node:fs/promises'
|
|
12
12
|
import { ServerResponse } from 'node:http'
|
|
13
13
|
import { register } from 'node:module'
|
|
14
14
|
import { hostname, platform, tmpdir } from 'node:os'
|
|
15
|
-
import { basename,
|
|
16
|
-
import { fileURLToPath } from 'node:url'
|
|
15
|
+
import { basename, resolve } from 'node:path'
|
|
17
16
|
import pino from 'pino'
|
|
18
17
|
import { Agent, Pool, setGlobalDispatcher } from 'undici'
|
|
19
18
|
import { WebSocket } from 'ws'
|
|
@@ -221,9 +220,7 @@ export class ChildProcess extends ITC {
|
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
async #collectMetrics ({ applicationId, workerId, metricsConfig }) {
|
|
224
|
-
|
|
225
|
-
// by the main runtime thread and duplicated with worker labels
|
|
226
|
-
await collectThreadMetrics(applicationId, workerId, metricsConfig, this.#metricsRegistry)
|
|
223
|
+
await collectMetrics(applicationId, workerId, metricsConfig, this.#metricsRegistry)
|
|
227
224
|
this.#setHttpCacheMetrics()
|
|
228
225
|
}
|
|
229
226
|
|
|
@@ -231,9 +228,7 @@ export class ChildProcess extends ITC {
|
|
|
231
228
|
clearRegistry(this.#metricsRegistry)
|
|
232
229
|
|
|
233
230
|
if (metricsConfig.enabled !== false) {
|
|
234
|
-
|
|
235
|
-
// by the main runtime thread and duplicated with worker labels
|
|
236
|
-
await collectThreadMetrics(applicationId, workerId, metricsConfig, this.#metricsRegistry)
|
|
231
|
+
await collectMetrics(applicationId, workerId, metricsConfig, this.#metricsRegistry)
|
|
237
232
|
this.#setHttpCacheMetrics()
|
|
238
233
|
}
|
|
239
234
|
}
|
|
@@ -508,60 +503,12 @@ function stripBasePath (basePath) {
|
|
|
508
503
|
}
|
|
509
504
|
}
|
|
510
505
|
|
|
511
|
-
// Enable compile cache if configured (Node.js 22.1.0+)
|
|
512
|
-
async function setupCompileCache (contextData) {
|
|
513
|
-
const config = contextData?.compileCache
|
|
514
|
-
|
|
515
|
-
// Normalize boolean shorthand
|
|
516
|
-
const normalizeConfig = cfg => {
|
|
517
|
-
if (cfg === true) return { enabled: true }
|
|
518
|
-
if (cfg === false) return { enabled: false }
|
|
519
|
-
return cfg
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
const normalizedConfig = normalizeConfig(config)
|
|
523
|
-
if (!normalizedConfig?.enabled) {
|
|
524
|
-
return
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
// Check if API is available (Node.js 22.1.0+)
|
|
528
|
-
let moduleApi
|
|
529
|
-
try {
|
|
530
|
-
moduleApi = await import('node:module')
|
|
531
|
-
if (typeof moduleApi.enableCompileCache !== 'function') {
|
|
532
|
-
return
|
|
533
|
-
}
|
|
534
|
-
} catch {
|
|
535
|
-
return
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
// Use root from context data (capability's this.root as URL)
|
|
539
|
-
const root = contextData?.root ? fileURLToPath(contextData.root) : null
|
|
540
|
-
if (!root) {
|
|
541
|
-
return
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const cacheDir =
|
|
545
|
-
typeof normalizedConfig === 'object' && normalizedConfig.directory
|
|
546
|
-
? normalizedConfig.directory
|
|
547
|
-
: join(root, '.plt', 'compile-cache')
|
|
548
|
-
|
|
549
|
-
try {
|
|
550
|
-
moduleApi.enableCompileCache(cacheDir)
|
|
551
|
-
} catch {
|
|
552
|
-
// Silently ignore - cache is optional optimization
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
506
|
async function main () {
|
|
557
507
|
const executable = basename(process.argv[1] ?? '')
|
|
558
508
|
|
|
559
509
|
const dataPath = resolve(tmpdir(), 'platformatic', 'runtimes', `${process.env.PLT_MANAGER_ID}.json`)
|
|
560
510
|
const { data, loader, scripts } = JSON.parse(await readFile(dataPath))
|
|
561
511
|
|
|
562
|
-
// Enable compile cache early before loading user modules
|
|
563
|
-
await setupCompileCache(data)
|
|
564
|
-
|
|
565
512
|
globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, data)
|
|
566
513
|
globalThis.platformatic.events = new ForwardingEventEmitter()
|
|
567
514
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.32.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"split2": "^4.2.0",
|
|
26
26
|
"undici": "^7.0.0",
|
|
27
27
|
"ws": "^8.18.0",
|
|
28
|
-
"@platformatic/foundation": "3.
|
|
29
|
-
"@platformatic/itc": "3.
|
|
30
|
-
"@platformatic/
|
|
31
|
-
"@platformatic/
|
|
28
|
+
"@platformatic/foundation": "3.32.0-alpha.0",
|
|
29
|
+
"@platformatic/itc": "3.32.0-alpha.0",
|
|
30
|
+
"@platformatic/telemetry": "3.32.0-alpha.0",
|
|
31
|
+
"@platformatic/metrics": "3.32.0-alpha.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"cleaner-spec-reporter": "^0.5.0",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/basic/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/basic/3.32.0-alpha.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Basic Config",
|
|
5
5
|
"type": "object",
|
|
@@ -212,6 +212,16 @@
|
|
|
212
212
|
"type": "string"
|
|
213
213
|
}
|
|
214
214
|
]
|
|
215
|
+
},
|
|
216
|
+
"noHeapCheck": {
|
|
217
|
+
"anyOf": [
|
|
218
|
+
{
|
|
219
|
+
"type": "boolean"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"type": "string"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
215
225
|
}
|
|
216
226
|
},
|
|
217
227
|
"additionalProperties": false
|
|
@@ -336,28 +346,6 @@
|
|
|
336
346
|
}
|
|
337
347
|
}
|
|
338
348
|
}
|
|
339
|
-
},
|
|
340
|
-
"compileCache": {
|
|
341
|
-
"anyOf": [
|
|
342
|
-
{
|
|
343
|
-
"type": "boolean"
|
|
344
|
-
},
|
|
345
|
-
{
|
|
346
|
-
"type": "object",
|
|
347
|
-
"properties": {
|
|
348
|
-
"enabled": {
|
|
349
|
-
"type": "boolean",
|
|
350
|
-
"default": true,
|
|
351
|
-
"description": "Enable Node.js module compile cache for faster startup"
|
|
352
|
-
},
|
|
353
|
-
"directory": {
|
|
354
|
-
"type": "string",
|
|
355
|
-
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
356
|
-
}
|
|
357
|
-
},
|
|
358
|
-
"additionalProperties": false
|
|
359
|
-
}
|
|
360
|
-
]
|
|
361
349
|
}
|
|
362
350
|
}
|
|
363
351
|
}
|
|
@@ -437,6 +425,7 @@
|
|
|
437
425
|
"properties": {
|
|
438
426
|
"level": {
|
|
439
427
|
"type": "string",
|
|
428
|
+
"default": "info",
|
|
440
429
|
"oneOf": [
|
|
441
430
|
{
|
|
442
431
|
"enum": [
|
|
@@ -579,6 +568,9 @@
|
|
|
579
568
|
"additionalProperties": true
|
|
580
569
|
}
|
|
581
570
|
},
|
|
571
|
+
"required": [
|
|
572
|
+
"level"
|
|
573
|
+
],
|
|
582
574
|
"default": {},
|
|
583
575
|
"additionalProperties": true
|
|
584
576
|
},
|
|
@@ -874,6 +866,17 @@
|
|
|
874
866
|
}
|
|
875
867
|
],
|
|
876
868
|
"default": 268435456
|
|
869
|
+
},
|
|
870
|
+
"noHeapCheck": {
|
|
871
|
+
"anyOf": [
|
|
872
|
+
{
|
|
873
|
+
"type": "boolean"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
"type": "string"
|
|
877
|
+
}
|
|
878
|
+
],
|
|
879
|
+
"default": false
|
|
877
880
|
}
|
|
878
881
|
},
|
|
879
882
|
"additionalProperties": false
|
|
@@ -1620,28 +1623,6 @@
|
|
|
1620
1623
|
],
|
|
1621
1624
|
"additionalProperties": false
|
|
1622
1625
|
},
|
|
1623
|
-
"compileCache": {
|
|
1624
|
-
"anyOf": [
|
|
1625
|
-
{
|
|
1626
|
-
"type": "boolean"
|
|
1627
|
-
},
|
|
1628
|
-
{
|
|
1629
|
-
"type": "object",
|
|
1630
|
-
"properties": {
|
|
1631
|
-
"enabled": {
|
|
1632
|
-
"type": "boolean",
|
|
1633
|
-
"default": true,
|
|
1634
|
-
"description": "Enable Node.js module compile cache for faster startup"
|
|
1635
|
-
},
|
|
1636
|
-
"directory": {
|
|
1637
|
-
"type": "string",
|
|
1638
|
-
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
1639
|
-
}
|
|
1640
|
-
},
|
|
1641
|
-
"additionalProperties": false
|
|
1642
|
-
}
|
|
1643
|
-
]
|
|
1644
|
-
},
|
|
1645
1626
|
"application": {
|
|
1646
1627
|
"type": "object",
|
|
1647
1628
|
"properties": {
|
|
@@ -1789,6 +1770,16 @@
|
|
|
1789
1770
|
"type": "string"
|
|
1790
1771
|
}
|
|
1791
1772
|
]
|
|
1773
|
+
},
|
|
1774
|
+
"noHeapCheck": {
|
|
1775
|
+
"anyOf": [
|
|
1776
|
+
{
|
|
1777
|
+
"type": "boolean"
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
"type": "string"
|
|
1781
|
+
}
|
|
1782
|
+
]
|
|
1792
1783
|
}
|
|
1793
1784
|
},
|
|
1794
1785
|
"additionalProperties": false
|
|
@@ -1906,28 +1897,6 @@
|
|
|
1906
1897
|
}
|
|
1907
1898
|
}
|
|
1908
1899
|
}
|
|
1909
|
-
},
|
|
1910
|
-
"compileCache": {
|
|
1911
|
-
"anyOf": [
|
|
1912
|
-
{
|
|
1913
|
-
"type": "boolean"
|
|
1914
|
-
},
|
|
1915
|
-
{
|
|
1916
|
-
"type": "object",
|
|
1917
|
-
"properties": {
|
|
1918
|
-
"enabled": {
|
|
1919
|
-
"type": "boolean",
|
|
1920
|
-
"default": true,
|
|
1921
|
-
"description": "Enable Node.js module compile cache for faster startup"
|
|
1922
|
-
},
|
|
1923
|
-
"directory": {
|
|
1924
|
-
"type": "string",
|
|
1925
|
-
"description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
|
|
1926
|
-
}
|
|
1927
|
-
},
|
|
1928
|
-
"additionalProperties": false
|
|
1929
|
-
}
|
|
1930
|
-
]
|
|
1931
1900
|
}
|
|
1932
1901
|
},
|
|
1933
1902
|
"additionalProperties": false
|