@platformatic/runtime 2.8.0 → 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/config.d.ts +1 -1
- package/lib/config.js +34 -7
- package/lib/runtime.js +11 -1
- package/lib/worker/main.js +1 -9
- package/package.json +14 -14
- package/schema.json +1 -1
package/config.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* and run json-schema-to-typescript to regenerate this file.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type HttpsSchemasPlatformaticDevPlatformaticRuntime281Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
package/lib/config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { readdir } = require('node:fs/promises')
|
|
4
|
-
const { join, resolve: pathResolve } = require('node:path')
|
|
4
|
+
const { join, resolve: pathResolve, isAbsolute } = require('node:path')
|
|
5
5
|
|
|
6
6
|
const ConfigManager = require('@platformatic/config')
|
|
7
|
+
const { Store } = require('@platformatic/config')
|
|
7
8
|
|
|
8
9
|
const errors = require('./errors')
|
|
9
10
|
const { schema } = require('./schema')
|
|
@@ -86,9 +87,40 @@ async function _transformConfig (configManager, args) {
|
|
|
86
87
|
for (let i = 0; i < services.length; ++i) {
|
|
87
88
|
const service = services[i]
|
|
88
89
|
|
|
90
|
+
// We need to have absolut paths here, ot the `loadConfig` will fail
|
|
91
|
+
if (!isAbsolute(service.path)) {
|
|
92
|
+
service.path = pathResolve(configManager.dirname, service.path)
|
|
93
|
+
}
|
|
94
|
+
|
|
89
95
|
if (configManager._fixPaths && service.config) {
|
|
90
96
|
service.config = pathResolve(service.path, service.config)
|
|
91
97
|
}
|
|
98
|
+
|
|
99
|
+
if (service.config) {
|
|
100
|
+
try {
|
|
101
|
+
const store = new Store({ cwd: service.path })
|
|
102
|
+
const serviceConfig = await store.loadConfig(service)
|
|
103
|
+
service.isPLTService = !!serviceConfig.app.isPLTService
|
|
104
|
+
service.type = serviceConfig.app.configType
|
|
105
|
+
} catch (err) {
|
|
106
|
+
// Fallback if for any reason a dependency is not found
|
|
107
|
+
try {
|
|
108
|
+
const manager = new ConfigManager({ source: pathResolve(service.path, service.config) })
|
|
109
|
+
await manager.parse()
|
|
110
|
+
const config = manager.current
|
|
111
|
+
const type = config.$schema ? ConfigManager.matchKnownSchema(config.$schema) : undefined
|
|
112
|
+
service.type = type
|
|
113
|
+
service.isPLTService = !!config.isPLTService
|
|
114
|
+
} catch (err) {
|
|
115
|
+
// This should not happen, it happens on running some unit tests if we prepare the runtime
|
|
116
|
+
// when not all the services configs are available. Given that we are running this only
|
|
117
|
+
// to ddetermine the type of the service, it's safe to ignore this error and default to unknown
|
|
118
|
+
service.type = 'unknown'
|
|
119
|
+
service.isPLTService = false
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
92
124
|
service.entrypoint = service.id === config.entrypoint
|
|
93
125
|
service.dependencies = []
|
|
94
126
|
service.localServiceEnvVars = new Map()
|
|
@@ -121,12 +153,7 @@ async function _transformConfig (configManager, args) {
|
|
|
121
153
|
continue
|
|
122
154
|
}
|
|
123
155
|
|
|
124
|
-
|
|
125
|
-
await manager.parse()
|
|
126
|
-
const config = manager.current
|
|
127
|
-
const type = config.$schema ? ConfigManager.matchKnownSchema(config.$schema) : undefined
|
|
128
|
-
|
|
129
|
-
if (type === 'composer') {
|
|
156
|
+
if (service.type === 'composer') {
|
|
130
157
|
composers.push(service.id)
|
|
131
158
|
}
|
|
132
159
|
}
|
package/lib/runtime.js
CHANGED
|
@@ -43,6 +43,9 @@ const COLLECT_METRICS_TIMEOUT = 1000
|
|
|
43
43
|
|
|
44
44
|
const MAX_BOOTSTRAP_ATTEMPTS = 5
|
|
45
45
|
|
|
46
|
+
const telemetryPath = require.resolve('@platformatic/telemetry')
|
|
47
|
+
const openTelemetrySetupPath = join(telemetryPath, '..', 'lib', 'node-http-telemetry.js')
|
|
48
|
+
|
|
46
49
|
class Runtime extends EventEmitter {
|
|
47
50
|
#configManager
|
|
48
51
|
#isProduction
|
|
@@ -753,6 +756,13 @@ class Runtime extends EventEmitter {
|
|
|
753
756
|
inspectorOptions.port = inspectorOptions.port + this.#workers.size + 1
|
|
754
757
|
}
|
|
755
758
|
|
|
759
|
+
if (config.telemetry) {
|
|
760
|
+
serviceConfig.telemetry = {
|
|
761
|
+
...config.telemetry,
|
|
762
|
+
serviceName: `${config.telemetry.serviceName}-${serviceConfig.id}`
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
|
|
756
766
|
const worker = new Worker(kWorkerFile, {
|
|
757
767
|
workerData: {
|
|
758
768
|
config,
|
|
@@ -770,7 +780,7 @@ class Runtime extends EventEmitter {
|
|
|
770
780
|
runtimeLogsDir: this.#runtimeLogsDir,
|
|
771
781
|
loggingPort
|
|
772
782
|
},
|
|
773
|
-
execArgv: []
|
|
783
|
+
execArgv: serviceConfig.isPLTService ? [] : ['--require', openTelemetrySetupPath],
|
|
774
784
|
env: this.#env,
|
|
775
785
|
transferList: [loggingPort],
|
|
776
786
|
/*
|
package/lib/worker/main.js
CHANGED
|
@@ -114,14 +114,6 @@ async function main () {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
let telemetryConfig = config.telemetry
|
|
118
|
-
if (telemetryConfig) {
|
|
119
|
-
telemetryConfig = {
|
|
120
|
-
...telemetryConfig,
|
|
121
|
-
serviceName: `${telemetryConfig.serviceName}-${service.id}`
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
117
|
const inspectorOptions = workerData.inspectorOptions
|
|
126
118
|
|
|
127
119
|
if (inspectorOptions) {
|
|
@@ -144,7 +136,7 @@ async function main () {
|
|
|
144
136
|
app = new PlatformaticApp(
|
|
145
137
|
service,
|
|
146
138
|
workerData.worker.count > 1 ? workerData.worker.index : undefined,
|
|
147
|
-
|
|
139
|
+
service.telemetry,
|
|
148
140
|
config.logger,
|
|
149
141
|
serverConfig,
|
|
150
142
|
config.metrics,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -35,12 +35,12 @@
|
|
|
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": "2.8.
|
|
39
|
-
"@platformatic/db": "2.8.
|
|
40
|
-
"@platformatic/node": "2.8.
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/sql-mapper": "2.8.
|
|
38
|
+
"@platformatic/composer": "2.8.1",
|
|
39
|
+
"@platformatic/db": "2.8.1",
|
|
40
|
+
"@platformatic/node": "2.8.1",
|
|
41
|
+
"@platformatic/sql-graphql": "2.8.1",
|
|
42
|
+
"@platformatic/service": "2.8.1",
|
|
43
|
+
"@platformatic/sql-mapper": "2.8.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@fastify/error": "^4.0.0",
|
|
@@ -71,13 +71,13 @@
|
|
|
71
71
|
"undici": "^6.9.0",
|
|
72
72
|
"undici-thread-interceptor": "^0.7.0",
|
|
73
73
|
"ws": "^8.16.0",
|
|
74
|
-
"@platformatic/basic": "2.8.
|
|
75
|
-
"@platformatic/
|
|
76
|
-
"@platformatic/
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
74
|
+
"@platformatic/basic": "2.8.1",
|
|
75
|
+
"@platformatic/config": "2.8.1",
|
|
76
|
+
"@platformatic/generators": "2.8.1",
|
|
77
|
+
"@platformatic/telemetry": "2.8.1",
|
|
78
|
+
"@platformatic/itc": "2.8.1",
|
|
79
|
+
"@platformatic/utils": "2.8.1",
|
|
80
|
+
"@platformatic/ts-compiler": "2.8.1"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED