@platformatic/runtime 3.61.1 → 3.62.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 +25 -0
- package/index.d.ts +32 -1
- package/lib/errors.js +25 -0
- package/lib/runtime.js +584 -85
- package/lib/worker/health-signals.js +34 -0
- package/lib/worker/main.js +18 -2
- package/package.json +18 -18
- package/schema.json +212 -1
package/config.d.ts
CHANGED
|
@@ -10,6 +10,23 @@ export type PlatformaticRuntimeConfig = {
|
|
|
10
10
|
} & {
|
|
11
11
|
$schema?: string;
|
|
12
12
|
preload?: string | string[];
|
|
13
|
+
extensions?:
|
|
14
|
+
| string
|
|
15
|
+
| {
|
|
16
|
+
path: string;
|
|
17
|
+
options?: {
|
|
18
|
+
[k: string]: unknown;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
| (
|
|
22
|
+
| string
|
|
23
|
+
| {
|
|
24
|
+
path: string;
|
|
25
|
+
options?: {
|
|
26
|
+
[k: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
)[];
|
|
13
30
|
entrypoint?: string;
|
|
14
31
|
basePath?: string;
|
|
15
32
|
autoload?: {
|
|
@@ -44,6 +61,8 @@ export type PlatformaticRuntimeConfig = {
|
|
|
44
61
|
gracePeriod?: number | string;
|
|
45
62
|
maxUnhealthyChecks?: number | string;
|
|
46
63
|
maxELU?: number | string;
|
|
64
|
+
maxEventLoopDelay?: number | string;
|
|
65
|
+
maxEventLoopDelayP99?: number | string;
|
|
47
66
|
maxHeapUsed?: number | string;
|
|
48
67
|
maxHeapTotal?: number | string;
|
|
49
68
|
maxYoungGeneration?: number | string;
|
|
@@ -51,6 +70,10 @@ export type PlatformaticRuntimeConfig = {
|
|
|
51
70
|
bufferPoolSize?: number | string;
|
|
52
71
|
defaultHighWaterMark?: number | string;
|
|
53
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Overrides the runtime-level restartOnError for this application. Set to false or 0 to never restart the application when it crashes, a positive number to wait that amount of milliseconds between restarts, or true to use the default delay.
|
|
75
|
+
*/
|
|
76
|
+
restartOnError?: boolean | number;
|
|
54
77
|
dependencies?: string[];
|
|
55
78
|
arguments?: string[];
|
|
56
79
|
env?: {
|
|
@@ -251,6 +274,8 @@ export type PlatformaticRuntimeConfig = {
|
|
|
251
274
|
gracePeriod?: number | string;
|
|
252
275
|
maxUnhealthyChecks?: number | string;
|
|
253
276
|
maxELU?: number | string;
|
|
277
|
+
maxEventLoopDelay?: number | string;
|
|
278
|
+
maxEventLoopDelayP99?: number | string;
|
|
254
279
|
maxHeapUsed?: number | string;
|
|
255
280
|
maxHeapTotal?: number | string;
|
|
256
281
|
maxYoungGeneration?: number | string;
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { BaseGenerator } from '@platformatic/generators'
|
|
|
4
4
|
import { PlatformaticGlobal } from '@platformatic/globals'
|
|
5
5
|
import { JSONSchemaType } from 'ajv'
|
|
6
6
|
import * as colorette from 'colorette'
|
|
7
|
+
import { EventEmitter } from 'node:events'
|
|
7
8
|
import { Logger } from 'pino'
|
|
8
9
|
import { PlatformaticRuntimeConfig } from './config.js'
|
|
9
10
|
|
|
@@ -52,6 +53,11 @@ export namespace errors {
|
|
|
52
53
|
export const InspectorHostError: () => FastifyError
|
|
53
54
|
export const CannotMapSpecifierToAbsolutePathError: (specifier: string) => FastifyError
|
|
54
55
|
export const NodeInspectorFlagsNotSupportedError: () => FastifyError
|
|
56
|
+
export const FailedToLoadExtensionError: (path: string, error: string) => FastifyError
|
|
57
|
+
export const InvalidExtensionError: (path: string) => FastifyError
|
|
58
|
+
export const ReservedITCHandlerNameError: (name: string) => FastifyError
|
|
59
|
+
export const DuplicateITCHandlerNameError: (name: string) => FastifyError
|
|
60
|
+
export const LastProfileTimeoutError: (id: string) => FastifyError
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
export namespace symbols {
|
|
@@ -148,7 +154,29 @@ export class WrappedGenerator extends BaseGenerator {}
|
|
|
148
154
|
|
|
149
155
|
export declare const schema: JSONSchemaType<PlatformaticRuntimeConfig>
|
|
150
156
|
|
|
151
|
-
export
|
|
157
|
+
export interface RuntimeExtensionITC {
|
|
158
|
+
handle (name: string, handler: (payload: any) => any): void
|
|
159
|
+
send<Response = unknown> (target: string, name: string, payload?: unknown): Promise<Response>
|
|
160
|
+
notify (target: string, name: string, payload?: unknown): Promise<void>
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface RuntimeExtensionContext {
|
|
164
|
+
runtime: Runtime
|
|
165
|
+
itc: RuntimeExtensionITC
|
|
166
|
+
logger: Logger
|
|
167
|
+
options: Record<string, unknown>
|
|
168
|
+
root: string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface RuntimeExtensionInstance {
|
|
172
|
+
close?: () => void | Promise<void>
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export type RuntimeExtension = (
|
|
176
|
+
context: RuntimeExtensionContext
|
|
177
|
+
) => void | RuntimeExtensionInstance | Promise<void | RuntimeExtensionInstance>
|
|
178
|
+
|
|
179
|
+
export declare class Runtime extends EventEmitter {
|
|
152
180
|
init (): Promise<void>
|
|
153
181
|
start (silent?: boolean): Promise<string | undefined>
|
|
154
182
|
stop (silent?: boolean): Promise<void>
|
|
@@ -167,6 +195,9 @@ export declare class Runtime {
|
|
|
167
195
|
restartApplication (id: string): Promise<void>
|
|
168
196
|
addApplications (applications: unknown[], start?: boolean): Promise<ApplicationDetails[]>
|
|
169
197
|
removeApplications (applications: string[], silent?: boolean): Promise<ApplicationDetails[]>
|
|
198
|
+
startApplicationProfiling (id: string, options?: Record<string, unknown>, ensureStarted?: boolean): Promise<void>
|
|
199
|
+
stopApplicationProfiling (id: string, options?: Record<string, unknown>, ensureStarted?: boolean): Promise<Buffer>
|
|
200
|
+
getApplicationLastProfile (id: string, options?: Record<string, unknown>, ensureStarted?: boolean): Promise<{ profile: Buffer, timestamp: number | null, preserved: boolean }>
|
|
170
201
|
}
|
|
171
202
|
|
|
172
203
|
export function wrapInRuntimeConfig (
|
package/lib/errors.js
CHANGED
|
@@ -145,6 +145,31 @@ export const MissingPprofCapture = createError(
|
|
|
145
145
|
'Please install @platformatic/wattpm-pprof-capture'
|
|
146
146
|
)
|
|
147
147
|
|
|
148
|
+
export const LastProfileTimeoutError = createError(
|
|
149
|
+
`${ERROR_PREFIX}_LAST_PROFILE_TIMEOUT`,
|
|
150
|
+
'Timed out while retrieving the last profile from the application "%s"'
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
export const FailedToLoadExtensionError = createError(
|
|
154
|
+
`${ERROR_PREFIX}_FAILED_TO_LOAD_EXTENSION`,
|
|
155
|
+
'Failed to load the extension "%s": %s'
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
export const InvalidExtensionError = createError(
|
|
159
|
+
`${ERROR_PREFIX}_INVALID_EXTENSION`,
|
|
160
|
+
'The extension "%s" must export a setup function as its default export'
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
export const ReservedITCHandlerNameError = createError(
|
|
164
|
+
`${ERROR_PREFIX}_RESERVED_ITC_HANDLER_NAME`,
|
|
165
|
+
'The ITC command name "%s" is reserved by the runtime'
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
export const DuplicateITCHandlerNameError = createError(
|
|
169
|
+
`${ERROR_PREFIX}_DUPLICATE_ITC_HANDLER_NAME`,
|
|
170
|
+
'The ITC command "%s" has already been registered'
|
|
171
|
+
)
|
|
172
|
+
|
|
148
173
|
export const FailedToSendHealthSignalsError = createError(
|
|
149
174
|
`${ERROR_PREFIX}_FAILED_TO_SEND_HEALTH_SIGNALS`,
|
|
150
175
|
'Cannot send health signals from application "%s": %s'
|