@platformatic/basic 2.8.0-alpha.2 → 2.8.1
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/base.js +7 -3
- package/lib/worker/child-manager.js +17 -3
- package/lib/worker/child-process.js +0 -9
- package/package.json +6 -6
- package/schema.json +1 -1
package/lib/base.js
CHANGED
|
@@ -38,7 +38,10 @@ export class BaseStackable {
|
|
|
38
38
|
this.startHttpTimer = null
|
|
39
39
|
this.endHttpTimer = null
|
|
40
40
|
this.clientWs = null
|
|
41
|
-
this.runtimeConfig = deepmerge(
|
|
41
|
+
this.runtimeConfig = deepmerge(
|
|
42
|
+
options.context?.runtimeConfig ?? {},
|
|
43
|
+
workerData?.config ?? {}
|
|
44
|
+
)
|
|
42
45
|
|
|
43
46
|
// Setup the logger
|
|
44
47
|
const pinoOptions = {
|
|
@@ -64,7 +67,8 @@ export class BaseStackable {
|
|
|
64
67
|
root: pathToFileURL(this.root).toString(),
|
|
65
68
|
setOpenapiSchema: this.setOpenapiSchema.bind(this),
|
|
66
69
|
setGraphqlSchema: this.setGraphqlSchema.bind(this),
|
|
67
|
-
setBasePath: this.setBasePath.bind(this)
|
|
70
|
+
setBasePath: this.setBasePath.bind(this),
|
|
71
|
+
runtimeBasePath: this.runtimeConfig?.basePath ?? null
|
|
68
72
|
})
|
|
69
73
|
}
|
|
70
74
|
|
|
@@ -356,7 +360,7 @@ export class BaseStackable {
|
|
|
356
360
|
/* c8 ignore next 2 */
|
|
357
361
|
port: (this.isEntrypoint ? this.serverConfig?.port || 0 : undefined) ?? true,
|
|
358
362
|
host: (this.isEntrypoint ? this.serverConfig?.hostname : undefined) ?? true,
|
|
359
|
-
|
|
363
|
+
telemetryConfig: this.telemetryConfig
|
|
360
364
|
}
|
|
361
365
|
}
|
|
362
366
|
}
|
|
@@ -3,14 +3,17 @@ import { createDirectory, ensureLoggableError } from '@platformatic/utils'
|
|
|
3
3
|
import { once } from 'node:events'
|
|
4
4
|
import { rm, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { createServer } from 'node:http'
|
|
6
|
+
import { pathToFileURL } from 'node:url'
|
|
6
7
|
import { register } from 'node:module'
|
|
7
8
|
import { platform, tmpdir } from 'node:os'
|
|
8
|
-
import { dirname, resolve } from 'node:path'
|
|
9
|
+
import { dirname, resolve, join } from 'node:path'
|
|
9
10
|
import { workerData } from 'node:worker_threads'
|
|
10
11
|
import { request } from 'undici'
|
|
11
12
|
import { WebSocketServer } from 'ws'
|
|
12
13
|
import { exitCodes } from '../errors.js'
|
|
13
14
|
import { ensureFileUrl } from '../utils.js'
|
|
15
|
+
import { createRequire } from 'node:module'
|
|
16
|
+
|
|
14
17
|
export const isWindows = platform() === 'win32'
|
|
15
18
|
|
|
16
19
|
// In theory we could use the context.id to namespace even more, but due to
|
|
@@ -160,8 +163,19 @@ export class ChildManager extends ITC {
|
|
|
160
163
|
)
|
|
161
164
|
|
|
162
165
|
process.env.PLT_MANAGER_ID = this.#id
|
|
163
|
-
|
|
164
|
-
|
|
166
|
+
|
|
167
|
+
const nodeOptions = process.env.NODE_OPTIONS ?? ''
|
|
168
|
+
const childProcessInclude = `--import="${new URL('./child-process.js', import.meta.url)}"`
|
|
169
|
+
|
|
170
|
+
let telemetryInclude = ''
|
|
171
|
+
if (this.#context.telemetryConfig) {
|
|
172
|
+
const require = createRequire(import.meta.url)
|
|
173
|
+
const telemetryPath = require.resolve('@platformatic/telemetry')
|
|
174
|
+
const openTelemetrySetupPath = join(telemetryPath, '..', 'lib', 'node-http-telemetry.js')
|
|
175
|
+
telemetryInclude = `--import="${pathToFileURL(openTelemetrySetupPath)}"`
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
process.env.NODE_OPTIONS = `${telemetryInclude} ${childProcessInclude} ${nodeOptions}`.trim()
|
|
165
179
|
}
|
|
166
180
|
|
|
167
181
|
async eject () {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ITC } from '@platformatic/itc'
|
|
2
2
|
import { collectMetrics } from '@platformatic/metrics'
|
|
3
|
-
import { setupNodeHTTPTelemetry } from '@platformatic/telemetry'
|
|
4
3
|
import { createPinoWritable, ensureLoggableError } from '@platformatic/utils'
|
|
5
4
|
import diagnosticChannel, { tracingChannel } from 'node:diagnostics_channel'
|
|
6
5
|
import { EventEmitter, once } from 'node:events'
|
|
@@ -109,7 +108,6 @@ export class ChildProcess extends ITC {
|
|
|
109
108
|
|
|
110
109
|
this.listen()
|
|
111
110
|
this.#setupLogger()
|
|
112
|
-
this.#setupTelemetry()
|
|
113
111
|
this.#setupHandlers()
|
|
114
112
|
this.#setupServer()
|
|
115
113
|
this.#setupInterceptors()
|
|
@@ -215,13 +213,6 @@ export class ChildProcess extends ITC {
|
|
|
215
213
|
}
|
|
216
214
|
}
|
|
217
215
|
|
|
218
|
-
/* c8 ignore next 5 */
|
|
219
|
-
#setupTelemetry () {
|
|
220
|
-
if (globalThis.platformatic.telemetry) {
|
|
221
|
-
setupNodeHTTPTelemetry(globalThis.platformatic.telemetry, this.#logger)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
216
|
#setupServer () {
|
|
226
217
|
const subscribers = {
|
|
227
218
|
asyncStart ({ options }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"split2": "^4.2.0",
|
|
24
24
|
"undici": "^6.19.5",
|
|
25
25
|
"ws": "^8.18.0",
|
|
26
|
-
"@platformatic/config": "2.8.
|
|
27
|
-
"@platformatic/itc": "2.8.
|
|
28
|
-
"@platformatic/
|
|
29
|
-
"@platformatic/
|
|
30
|
-
"@platformatic/
|
|
26
|
+
"@platformatic/config": "2.8.1",
|
|
27
|
+
"@platformatic/itc": "2.8.1",
|
|
28
|
+
"@platformatic/metrics": "2.8.1",
|
|
29
|
+
"@platformatic/utils": "2.8.1",
|
|
30
|
+
"@platformatic/telemetry": "2.8.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"borp": "^0.18.0",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.8.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/basic/2.8.1.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Stackable",
|
|
5
5
|
"type": "object",
|