@platformatic/runtime 1.5.2 → 1.6.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/fixtures/server/logger-transport/custom-transport.js +15 -0
- package/fixtures/server/logger-transport/platformatic.runtime.json +22 -0
- package/fixtures/server/logger-transport/services/echo/platformatic.service.json +12 -0
- package/fixtures/server/logger-transport/services/echo/routes/hello.js +6 -0
- package/fixtures/server/runtime-server/platformatic.runtime.json +1 -1
- package/fixtures/server/runtime-server/services/echo/routes/hello.js +6 -0
- package/lib/worker.js +23 -8
- package/package.json +10 -9
- package/fixtures/server/runtime-server/services/echo/routes/span.js +0 -8
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const build = require('pino-abstract-transport')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
|
|
7
|
+
module.exports = function (opts) {
|
|
8
|
+
const dest = opts.path || path.join(process.cwd(), 'transport.log')
|
|
9
|
+
return build(function (source) {
|
|
10
|
+
source.on('data', function (obj) {
|
|
11
|
+
obj.fromTransport = true
|
|
12
|
+
fs.appendFileSync(dest, JSON.stringify(obj) + '\n')
|
|
13
|
+
})
|
|
14
|
+
})
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://platformatic.dev/schemas/v0.31.0/runtime",
|
|
3
|
+
"entrypoint": "echo",
|
|
4
|
+
"allowCycles": false,
|
|
5
|
+
"hotReload": true,
|
|
6
|
+
"autoload": {
|
|
7
|
+
"path": "services",
|
|
8
|
+
"exclude": [
|
|
9
|
+
"docs"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"server": {
|
|
13
|
+
"hostname": "127.0.0.1",
|
|
14
|
+
"port": "14242",
|
|
15
|
+
"logger": {
|
|
16
|
+
"level": "info",
|
|
17
|
+
"transport": {
|
|
18
|
+
"target": "./custom-transport.js"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/lib/worker.js
CHANGED
|
@@ -28,26 +28,40 @@ if (typeof register === 'function' && workerData.config.loaderFile) {
|
|
|
28
28
|
|
|
29
29
|
globalThis.fetch = undici.fetch
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
const config = workerData.config
|
|
32
|
+
|
|
33
|
+
let loggerConfig = config.server?.logger
|
|
32
34
|
let destination
|
|
33
35
|
|
|
36
|
+
if (loggerConfig) {
|
|
37
|
+
loggerConfig = { ...loggerConfig }
|
|
38
|
+
} else {
|
|
39
|
+
loggerConfig = {}
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
/* c8 ignore next 10 */
|
|
35
|
-
if (
|
|
43
|
+
if (config.loggingPort) {
|
|
36
44
|
destination = new MessagePortWritable({
|
|
37
|
-
metadata:
|
|
38
|
-
port:
|
|
45
|
+
metadata: config.loggingMetadata,
|
|
46
|
+
port: config.loggingPort
|
|
39
47
|
})
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
delete loggerConfig.transport
|
|
49
|
+
} else if (!loggerConfig.transport && isatty(1)) {
|
|
50
|
+
loggerConfig.transport = {
|
|
42
51
|
target: 'pino-pretty'
|
|
43
|
-
}
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
const logger = pino(
|
|
55
|
+
const logger = pino(loggerConfig, destination)
|
|
56
|
+
|
|
57
|
+
if (config.server) {
|
|
58
|
+
config.server.logger = logger
|
|
59
|
+
}
|
|
47
60
|
|
|
48
61
|
/* c8 ignore next 4 */
|
|
49
62
|
process.once('uncaughtException', (err) => {
|
|
50
63
|
logger.error({ err }, 'runtime error')
|
|
64
|
+
logger[pino.symbols.streamSym].flushSync?.()
|
|
51
65
|
setImmediate(() => {
|
|
52
66
|
process.exit(1)
|
|
53
67
|
})
|
|
@@ -57,6 +71,7 @@ process.once('uncaughtException', (err) => {
|
|
|
57
71
|
/* c8 ignore next 4 */
|
|
58
72
|
process.once('unhandledRejection', (err) => {
|
|
59
73
|
logger.error({ err }, 'runtime error')
|
|
74
|
+
logger[pino.symbols.streamSym].flushSync?.()
|
|
60
75
|
setImmediate(() => {
|
|
61
76
|
process.exit(1)
|
|
62
77
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
"execa": "^8.0.1",
|
|
23
23
|
"express": "^4.18.2",
|
|
24
24
|
"glob": "^10.3.10",
|
|
25
|
+
"pino-abstract-transport": "^1.1.0",
|
|
25
26
|
"snazzy": "^9.0.0",
|
|
26
27
|
"split2": "^4.2.0",
|
|
27
28
|
"standard": "^17.1.0",
|
|
28
29
|
"tsd": "^0.29.0",
|
|
29
30
|
"typescript": "^5.2.2",
|
|
30
|
-
"@platformatic/sql-graphql": "1.
|
|
31
|
-
"@platformatic/sql-mapper": "1.
|
|
31
|
+
"@platformatic/sql-graphql": "1.6.1",
|
|
32
|
+
"@platformatic/sql-mapper": "1.6.1"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@fastify/error": "^3.4.0",
|
|
@@ -47,12 +48,12 @@
|
|
|
47
48
|
"pino": "^8.16.0",
|
|
48
49
|
"pino-pretty": "^10.2.3",
|
|
49
50
|
"undici": "^5.26.3",
|
|
50
|
-
"@platformatic/
|
|
51
|
-
"@platformatic/
|
|
52
|
-
"@platformatic/db": "1.
|
|
53
|
-
"@platformatic/service": "1.
|
|
54
|
-
"@platformatic/telemetry": "1.
|
|
55
|
-
"@platformatic/utils": "1.
|
|
51
|
+
"@platformatic/config": "1.6.1",
|
|
52
|
+
"@platformatic/composer": "1.6.1",
|
|
53
|
+
"@platformatic/db": "1.6.1",
|
|
54
|
+
"@platformatic/service": "1.6.1",
|
|
55
|
+
"@platformatic/telemetry": "1.6.1",
|
|
56
|
+
"@platformatic/utils": "1.6.1"
|
|
56
57
|
},
|
|
57
58
|
"standard": {
|
|
58
59
|
"ignore": [
|