@platformatic/basic 3.17.0 → 3.18.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/lib/capability.js +5 -0
- package/lib/worker/child-process.js +14 -15
- package/package.json +5 -5
- package/schema.json +2 -3
package/lib/capability.js
CHANGED
|
@@ -564,6 +564,11 @@ export class BaseCapability extends EventEmitter {
|
|
|
564
564
|
async getChildManagerContext (basePath) {
|
|
565
565
|
const meta = await this.getMeta()
|
|
566
566
|
|
|
567
|
+
// This is needed to correctly handle reusePort in child processes when using build
|
|
568
|
+
if (this.reuseTcpPorts && !features.node.reusePort) {
|
|
569
|
+
this.reuseTcpPorts = false
|
|
570
|
+
}
|
|
571
|
+
|
|
567
572
|
return {
|
|
568
573
|
id: this.id,
|
|
569
574
|
config: this.config,
|
|
@@ -13,7 +13,6 @@ import { ServerResponse } from 'node:http'
|
|
|
13
13
|
import { register } from 'node:module'
|
|
14
14
|
import { hostname, platform, tmpdir } from 'node:os'
|
|
15
15
|
import { basename, resolve } from 'node:path'
|
|
16
|
-
import { isMainThread } from 'node:worker_threads'
|
|
17
16
|
import pino from 'pino'
|
|
18
17
|
import { Agent, Pool, setGlobalDispatcher } from 'undici'
|
|
19
18
|
import { WebSocket } from 'ws'
|
|
@@ -77,7 +76,7 @@ export class ChildProcess extends ITC {
|
|
|
77
76
|
#metricsRegistry
|
|
78
77
|
#pendingMessages
|
|
79
78
|
|
|
80
|
-
constructor () {
|
|
79
|
+
constructor (executable) {
|
|
81
80
|
super({
|
|
82
81
|
throwOnMissingHandler: false,
|
|
83
82
|
name: `${process.env.PLT_MANAGER_ID}-child-process`,
|
|
@@ -121,17 +120,20 @@ export class ChildProcess extends ITC {
|
|
|
121
120
|
this.#metricsRegistry = new client.Registry()
|
|
122
121
|
|
|
123
122
|
this.listen()
|
|
124
|
-
this.#setupLogger()
|
|
125
123
|
|
|
126
|
-
if (
|
|
127
|
-
this.#
|
|
128
|
-
|
|
124
|
+
if (!windowsNpmExecutables.includes(executable)) {
|
|
125
|
+
this.#setupLogger()
|
|
126
|
+
|
|
127
|
+
if (globalThis.platformatic.exitOnUnhandledErrors) {
|
|
128
|
+
this.#setupHandlers()
|
|
129
|
+
}
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
this.#setupServer()
|
|
132
|
+
this.#setupInterceptors()
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
|
|
134
|
+
if (globalThis.platformatic.reuseTcpPorts) {
|
|
135
|
+
this.#setupTcpPortsHandling()
|
|
136
|
+
}
|
|
135
137
|
}
|
|
136
138
|
|
|
137
139
|
this.registerGlobals({
|
|
@@ -487,14 +489,11 @@ function stripBasePath (basePath) {
|
|
|
487
489
|
|
|
488
490
|
async function main () {
|
|
489
491
|
const executable = basename(process.argv[1] ?? '')
|
|
490
|
-
if (!isMainThread || windowsNpmExecutables.includes(executable)) {
|
|
491
|
-
return
|
|
492
|
-
}
|
|
493
492
|
|
|
494
493
|
const dataPath = resolve(tmpdir(), 'platformatic', 'runtimes', `${process.env.PLT_MANAGER_ID}.json`)
|
|
495
494
|
const { data, loader, scripts } = JSON.parse(await readFile(dataPath))
|
|
496
495
|
|
|
497
|
-
globalThis.platformatic = data
|
|
496
|
+
globalThis.platformatic = Object.assign(globalThis.platformatic ?? {}, data)
|
|
498
497
|
globalThis.platformatic.events = new ForwardingEventEmitter()
|
|
499
498
|
|
|
500
499
|
if (loader) {
|
|
@@ -505,7 +504,7 @@ async function main () {
|
|
|
505
504
|
await importFile(script)
|
|
506
505
|
}
|
|
507
506
|
|
|
508
|
-
const childProcess = new ChildProcess()
|
|
507
|
+
const childProcess = new ChildProcess(executable)
|
|
509
508
|
globalThis[Symbol.for('plt.children.itc')] = childProcess
|
|
510
509
|
globalThis.platformatic.itc = childProcess
|
|
511
510
|
globalThis.platformatic.events.target = childProcess
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.18.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/
|
|
30
|
-
"@platformatic/
|
|
31
|
-
"@platformatic/telemetry": "3.
|
|
28
|
+
"@platformatic/foundation": "3.18.0",
|
|
29
|
+
"@platformatic/metrics": "3.18.0",
|
|
30
|
+
"@platformatic/itc": "3.18.0",
|
|
31
|
+
"@platformatic/telemetry": "3.18.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.18.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Basic Config",
|
|
5
5
|
"type": "object",
|
|
@@ -784,8 +784,7 @@
|
|
|
784
784
|
{
|
|
785
785
|
"type": "string"
|
|
786
786
|
}
|
|
787
|
-
]
|
|
788
|
-
"default": 4294967296
|
|
787
|
+
]
|
|
789
788
|
},
|
|
790
789
|
"maxYoungGeneration": {
|
|
791
790
|
"anyOf": [
|