@platformatic/runtime 2.8.0-alpha.1 → 2.8.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 +6 -2
- package/lib/runtime.js +3 -2
- package/lib/schema.js +40 -9
- package/package.json +20 -14
- package/schema.json +63 -7
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 HttpsSchemasPlatformaticDevPlatformaticRuntime280Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
|
@@ -26,7 +26,7 @@ export type HttpsSchemasPlatformaticDevPlatformaticRuntime280Alpha1Json = {
|
|
|
26
26
|
services?: {
|
|
27
27
|
[k: string]: unknown;
|
|
28
28
|
}[];
|
|
29
|
-
workers?: number;
|
|
29
|
+
workers?: number | string;
|
|
30
30
|
web?: {
|
|
31
31
|
[k: string]: unknown;
|
|
32
32
|
}[];
|
|
@@ -97,6 +97,10 @@ export type HttpsSchemasPlatformaticDevPlatformaticRuntime280Alpha1Json = {
|
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
restartOnError?: boolean | number;
|
|
100
|
+
gracefulShutdown?: {
|
|
101
|
+
runtime: number | string;
|
|
102
|
+
service: number | string;
|
|
103
|
+
};
|
|
100
104
|
undici?: {
|
|
101
105
|
agentOptions?: {
|
|
102
106
|
[k: string]: unknown;
|
package/lib/runtime.js
CHANGED
|
@@ -979,11 +979,12 @@ class Runtime extends EventEmitter {
|
|
|
979
979
|
this.logger?.info(`Stopping the ${label}...`)
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
+
const exitTimeout = this.#configManager.current.gracefulShutdown.runtime
|
|
982
983
|
const exitPromise = once(worker, 'exit')
|
|
983
984
|
|
|
984
985
|
// Always send the stop message, it will shut down workers that only had ITC and interceptors setup
|
|
985
986
|
try {
|
|
986
|
-
await executeWithTimeout(sendViaITC(worker, 'stop'),
|
|
987
|
+
await executeWithTimeout(sendViaITC(worker, 'stop'), exitTimeout)
|
|
987
988
|
} catch (error) {
|
|
988
989
|
this.logger?.info({ error: ensureLoggableError(error) }, `Failed to stop ${label}. Killing a worker thread.`)
|
|
989
990
|
} finally {
|
|
@@ -995,7 +996,7 @@ class Runtime extends EventEmitter {
|
|
|
995
996
|
}
|
|
996
997
|
|
|
997
998
|
// Wait for the worker thread to finish, we're going to create a new one if the service is ever restarted
|
|
998
|
-
const res = await executeWithTimeout(exitPromise,
|
|
999
|
+
const res = await executeWithTimeout(exitPromise, exitTimeout)
|
|
999
1000
|
|
|
1000
1001
|
// If the worker didn't exit in time, kill it
|
|
1001
1002
|
if (res === 'timeout') {
|
package/lib/schema.js
CHANGED
|
@@ -6,6 +6,16 @@ const {
|
|
|
6
6
|
schemaComponents: { server, logger }
|
|
7
7
|
} = require('@platformatic/utils')
|
|
8
8
|
|
|
9
|
+
const workers = {
|
|
10
|
+
anyOf: [
|
|
11
|
+
{
|
|
12
|
+
type: 'number',
|
|
13
|
+
minimum: 1
|
|
14
|
+
},
|
|
15
|
+
{ type: 'string' }
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
const services = {
|
|
10
20
|
type: 'array',
|
|
11
21
|
items: {
|
|
@@ -28,10 +38,7 @@ const services = {
|
|
|
28
38
|
useHttp: {
|
|
29
39
|
type: 'boolean'
|
|
30
40
|
},
|
|
31
|
-
workers
|
|
32
|
-
type: 'number',
|
|
33
|
-
minimum: 1
|
|
34
|
-
}
|
|
41
|
+
workers
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
}
|
|
@@ -94,11 +101,7 @@ const platformaticRuntimeSchema = {
|
|
|
94
101
|
}
|
|
95
102
|
},
|
|
96
103
|
services,
|
|
97
|
-
workers: {
|
|
98
|
-
type: 'number',
|
|
99
|
-
minimum: 1,
|
|
100
|
-
default: 1
|
|
101
|
-
},
|
|
104
|
+
workers: { ...workers, default: 1 },
|
|
102
105
|
web: services,
|
|
103
106
|
logger,
|
|
104
107
|
server,
|
|
@@ -112,6 +115,34 @@ const platformaticRuntimeSchema = {
|
|
|
112
115
|
}
|
|
113
116
|
]
|
|
114
117
|
},
|
|
118
|
+
gracefulShutdown: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
properties: {
|
|
121
|
+
runtime: {
|
|
122
|
+
anyOf: [
|
|
123
|
+
{
|
|
124
|
+
type: 'number',
|
|
125
|
+
minimum: 1
|
|
126
|
+
},
|
|
127
|
+
{ type: 'string' }
|
|
128
|
+
],
|
|
129
|
+
default: 10000
|
|
130
|
+
},
|
|
131
|
+
service: {
|
|
132
|
+
anyOf: [
|
|
133
|
+
{
|
|
134
|
+
type: 'number',
|
|
135
|
+
minimum: 1
|
|
136
|
+
},
|
|
137
|
+
{ type: 'string' }
|
|
138
|
+
],
|
|
139
|
+
default: 10000
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
default: {},
|
|
143
|
+
required: ['runtime', 'service'],
|
|
144
|
+
additionalProperties: false
|
|
145
|
+
},
|
|
115
146
|
undici: {
|
|
116
147
|
type: 'object',
|
|
117
148
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.8.0
|
|
3
|
+
"version": "2.8.0",
|
|
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.0
|
|
39
|
-
"@platformatic/db": "2.8.0
|
|
40
|
-
"@platformatic/node": "2.8.0
|
|
41
|
-
"@platformatic/service": "2.8.0
|
|
42
|
-
"@platformatic/sql-graphql": "2.8.0
|
|
43
|
-
"@platformatic/sql-mapper": "2.8.0
|
|
38
|
+
"@platformatic/composer": "2.8.0",
|
|
39
|
+
"@platformatic/db": "2.8.0",
|
|
40
|
+
"@platformatic/node": "2.8.0",
|
|
41
|
+
"@platformatic/service": "2.8.0",
|
|
42
|
+
"@platformatic/sql-graphql": "2.8.0",
|
|
43
|
+
"@platformatic/sql-mapper": "2.8.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@fastify/error": "^4.0.0",
|
|
@@ -71,16 +71,22 @@
|
|
|
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.0
|
|
75
|
-
"@platformatic/generators": "2.8.0
|
|
76
|
-
"@platformatic/config": "2.8.0
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/ts-compiler": "2.8.0
|
|
80
|
-
"@platformatic/utils": "2.8.0
|
|
74
|
+
"@platformatic/basic": "2.8.0",
|
|
75
|
+
"@platformatic/generators": "2.8.0",
|
|
76
|
+
"@platformatic/config": "2.8.0",
|
|
77
|
+
"@platformatic/itc": "2.8.0",
|
|
78
|
+
"@platformatic/telemetry": "2.8.0",
|
|
79
|
+
"@platformatic/ts-compiler": "2.8.0",
|
|
80
|
+
"@platformatic/utils": "2.8.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
|
84
|
+
"test:main": "borp --concurrency=1 --timeout=300000 test/*.test.js test/versions/*.test.js",
|
|
85
|
+
"test:api": "borp --concurrency=1 --timeout=300000 test/api/*.test.js test/management-api/*.test.js",
|
|
86
|
+
"test:cli": "borp --concurrency=1 --timeout=300000 test/cli/*.test.js test/cli/**/*.test.js",
|
|
87
|
+
"test:start": "borp --concurrency=1 --timeout=300000 test/start/*.test.js",
|
|
88
|
+
"test:multiple-workers": "borp --concurrency=1 --timeout=300000 test/multiple-workers/*.test.js",
|
|
89
|
+
"test:types": "tsd",
|
|
84
90
|
"coverage": "npm run lint && borp -X fixtures -X test -C --concurrency=1 --timeout=300000 && tsd",
|
|
85
91
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
86
92
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.8.0
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.8.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
@@ -93,15 +93,29 @@
|
|
|
93
93
|
"type": "boolean"
|
|
94
94
|
},
|
|
95
95
|
"workers": {
|
|
96
|
-
"
|
|
97
|
-
|
|
96
|
+
"anyOf": [
|
|
97
|
+
{
|
|
98
|
+
"type": "number",
|
|
99
|
+
"minimum": 1
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
]
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
}
|
|
101
108
|
},
|
|
102
109
|
"workers": {
|
|
103
|
-
"
|
|
104
|
-
|
|
110
|
+
"anyOf": [
|
|
111
|
+
{
|
|
112
|
+
"type": "number",
|
|
113
|
+
"minimum": 1
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"type": "string"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
105
119
|
"default": 1
|
|
106
120
|
},
|
|
107
121
|
"web": {
|
|
@@ -140,8 +154,15 @@
|
|
|
140
154
|
"type": "boolean"
|
|
141
155
|
},
|
|
142
156
|
"workers": {
|
|
143
|
-
"
|
|
144
|
-
|
|
157
|
+
"anyOf": [
|
|
158
|
+
{
|
|
159
|
+
"type": "number",
|
|
160
|
+
"minimum": 1
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"type": "string"
|
|
164
|
+
}
|
|
165
|
+
]
|
|
145
166
|
}
|
|
146
167
|
}
|
|
147
168
|
}
|
|
@@ -353,6 +374,41 @@
|
|
|
353
374
|
}
|
|
354
375
|
]
|
|
355
376
|
},
|
|
377
|
+
"gracefulShutdown": {
|
|
378
|
+
"type": "object",
|
|
379
|
+
"properties": {
|
|
380
|
+
"runtime": {
|
|
381
|
+
"anyOf": [
|
|
382
|
+
{
|
|
383
|
+
"type": "number",
|
|
384
|
+
"minimum": 1
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
"type": "string"
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
"default": 10000
|
|
391
|
+
},
|
|
392
|
+
"service": {
|
|
393
|
+
"anyOf": [
|
|
394
|
+
{
|
|
395
|
+
"type": "number",
|
|
396
|
+
"minimum": 1
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"type": "string"
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
"default": 10000
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
"default": {},
|
|
406
|
+
"required": [
|
|
407
|
+
"runtime",
|
|
408
|
+
"service"
|
|
409
|
+
],
|
|
410
|
+
"additionalProperties": false
|
|
411
|
+
},
|
|
356
412
|
"undici": {
|
|
357
413
|
"type": "object",
|
|
358
414
|
"properties": {
|