@platformatic/runtime 2.10.0 → 2.11.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 +2 -1
- package/lib/errors.js +1 -0
- package/lib/runtime.js +22 -5
- package/lib/schema.js +5 -0
- package/package.json +14 -15
- package/schema.json +6 -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 HttpsSchemasPlatformaticDevPlatformaticRuntime2110Json = {
|
|
9
9
|
[k: string]: unknown;
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
|
@@ -104,6 +104,7 @@ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2100Json = {
|
|
|
104
104
|
)[];
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
|
+
startTimeout?: number;
|
|
107
108
|
restartOnError?: boolean | number;
|
|
108
109
|
gracefulShutdown?: {
|
|
109
110
|
runtime: number | string;
|
package/lib/errors.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = {
|
|
|
13
13
|
UnknownRuntimeAPICommandError: createError(`${ERROR_PREFIX}_UNKNOWN_RUNTIME_API_COMMAND`, 'Unknown Runtime API command "%s"'),
|
|
14
14
|
ServiceNotFoundError: createError(`${ERROR_PREFIX}_SERVICE_NOT_FOUND`, 'Service %s not found. Available services are: %s'),
|
|
15
15
|
ServiceNotStartedError: createError(`${ERROR_PREFIX}_SERVICE_NOT_STARTED`, "Service with id '%s' is not started"),
|
|
16
|
+
ServiceStartTimeoutError: createError(`${ERROR_PREFIX}_SERVICE_START_TIMEOUT`, "Service with id '%s' failed to start in %dms."),
|
|
16
17
|
FailedToRetrieveOpenAPISchemaError: createError(`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_OPENAPI_SCHEMA`, 'Failed to retrieve OpenAPI schema for service with id "%s": %s'),
|
|
17
18
|
FailedToRetrieveGraphQLSchemaError: createError(`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_GRAPHQL_SCHEMA`, 'Failed to retrieve GraphQL schema for service with id "%s": %s'),
|
|
18
19
|
FailedToRetrieveMetaError: createError(`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_META`, 'Failed to retrieve metadata for service with id "%s": %s'),
|
package/lib/runtime.js
CHANGED
|
@@ -973,7 +973,19 @@ class Runtime extends EventEmitter {
|
|
|
973
973
|
worker[kWorkerStatus] = 'starting'
|
|
974
974
|
|
|
975
975
|
try {
|
|
976
|
-
|
|
976
|
+
let workerUrl
|
|
977
|
+
if (config.startTimeout > 0) {
|
|
978
|
+
workerUrl = await executeWithTimeout(sendViaITC(worker, 'start'), config.startTimeout)
|
|
979
|
+
|
|
980
|
+
if (workerUrl === 'timeout') {
|
|
981
|
+
this.logger.info(`The ${label} failed to start in ${config.startTimeout}ms. Forcefully killing the thread.`)
|
|
982
|
+
worker.terminate()
|
|
983
|
+
throw new errors.ServiceStartTimeoutError(id, config.startTimeout)
|
|
984
|
+
}
|
|
985
|
+
} else {
|
|
986
|
+
workerUrl = await sendViaITC(worker, 'start')
|
|
987
|
+
}
|
|
988
|
+
|
|
977
989
|
if (workerUrl) {
|
|
978
990
|
this.#url = workerUrl
|
|
979
991
|
}
|
|
@@ -986,9 +998,12 @@ class Runtime extends EventEmitter {
|
|
|
986
998
|
|
|
987
999
|
const { enabled, gracePeriod } = worker[kConfig].health
|
|
988
1000
|
if (enabled && config.restartOnError > 0) {
|
|
989
|
-
worker[kHealthCheckTimer] = setTimeout(
|
|
990
|
-
|
|
991
|
-
|
|
1001
|
+
worker[kHealthCheckTimer] = setTimeout(
|
|
1002
|
+
() => {
|
|
1003
|
+
this.#setupHealthCheck(worker, label)
|
|
1004
|
+
},
|
|
1005
|
+
gracePeriod > 0 ? gracePeriod : 1
|
|
1006
|
+
)
|
|
992
1007
|
}
|
|
993
1008
|
} catch (error) {
|
|
994
1009
|
// TODO: handle port allocation error here
|
|
@@ -1002,7 +1017,9 @@ class Runtime extends EventEmitter {
|
|
|
1002
1017
|
await worker.terminate()
|
|
1003
1018
|
}
|
|
1004
1019
|
|
|
1005
|
-
|
|
1020
|
+
if (error.code !== 'PLT_RUNTIME_SERVICE_START_TIMEOUT') {
|
|
1021
|
+
this.logger.error({ err: ensureLoggableError(error) }, `Failed to start ${label}.`)
|
|
1022
|
+
}
|
|
1006
1023
|
|
|
1007
1024
|
const restartOnError = config.restartOnError
|
|
1008
1025
|
|
package/lib/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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.
|
|
39
|
-
"@platformatic/db": "2.
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/sql-
|
|
43
|
-
"@platformatic/sql-
|
|
38
|
+
"@platformatic/composer": "2.11.0",
|
|
39
|
+
"@platformatic/db": "2.11.0",
|
|
40
|
+
"@platformatic/service": "2.11.0",
|
|
41
|
+
"@platformatic/node": "2.11.0",
|
|
42
|
+
"@platformatic/sql-graphql": "2.11.0",
|
|
43
|
+
"@platformatic/sql-mapper": "2.11.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@fastify/error": "^4.0.0",
|
|
@@ -67,17 +67,16 @@
|
|
|
67
67
|
"prom-client": "^15.1.2",
|
|
68
68
|
"semgrator": "^0.3.0",
|
|
69
69
|
"tail-file-stream": "^0.2.0",
|
|
70
|
-
"thread-cpu-usage": "^0.2.0",
|
|
71
70
|
"undici": "^6.9.0",
|
|
72
71
|
"undici-thread-interceptor": "^0.8.0",
|
|
73
72
|
"ws": "^8.16.0",
|
|
74
|
-
"@platformatic/basic": "2.
|
|
75
|
-
"@platformatic/
|
|
76
|
-
"@platformatic/
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/telemetry": "2.
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
73
|
+
"@platformatic/basic": "2.11.0",
|
|
74
|
+
"@platformatic/config": "2.11.0",
|
|
75
|
+
"@platformatic/itc": "2.11.0",
|
|
76
|
+
"@platformatic/generators": "2.11.0",
|
|
77
|
+
"@platformatic/telemetry": "2.11.0",
|
|
78
|
+
"@platformatic/ts-compiler": "2.11.0",
|
|
79
|
+
"@platformatic/utils": "2.11.0"
|
|
81
80
|
},
|
|
82
81
|
"scripts": {
|
|
83
82
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.11.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
@@ -654,6 +654,11 @@
|
|
|
654
654
|
},
|
|
655
655
|
"additionalProperties": false
|
|
656
656
|
},
|
|
657
|
+
"startTimeout": {
|
|
658
|
+
"default": 30000,
|
|
659
|
+
"type": "number",
|
|
660
|
+
"minimum": 0
|
|
661
|
+
},
|
|
657
662
|
"restartOnError": {
|
|
658
663
|
"default": true,
|
|
659
664
|
"anyOf": [
|