@platformatic/runtime 3.0.6 → 3.2.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 CHANGED
@@ -249,8 +249,7 @@ export type PlatformaticRuntimeConfig = {
249
249
  body?: string;
250
250
  };
251
251
  };
252
- additionalProperties?: never;
253
- [k: string]: unknown;
252
+ plugins?: string[];
254
253
  };
255
254
  telemetry?: {
256
255
  enabled?: boolean | string;
package/lib/generator.js CHANGED
@@ -30,7 +30,7 @@ const wrappableProperties = {
30
30
  }
31
31
 
32
32
  const engines = {
33
- node: '>=22.18.0'
33
+ node: '>=22.19.0'
34
34
  }
35
35
 
36
36
  export const ERROR_PREFIX = 'PLT_RUNTIME_GEN'
@@ -1,6 +1,9 @@
1
1
  import fastifyAccepts from '@fastify/accepts'
2
2
  import fastifyBasicAuth from '@fastify/basic-auth'
3
+ import { loadModule } from '@platformatic/foundation'
3
4
  import fastify from 'fastify'
5
+ import { createRequire } from 'node:module'
6
+ import { resolve } from 'node:path'
4
7
 
5
8
  const DEFAULT_HOSTNAME = '0.0.0.0'
6
9
  const DEFAULT_PORT = 9090
@@ -218,6 +221,12 @@ export async function startPrometheusServer (runtime, opts) {
218
221
  })
219
222
  }
220
223
 
224
+ const require = createRequire(resolve(import.meta.filename))
225
+ for (const pluginPath of opts.plugins ?? []) {
226
+ const plugin = await loadModule(require, pluginPath)
227
+ await promServer.register(plugin)
228
+ }
229
+
221
230
  await promServer.listen({ port, host })
222
231
  return promServer
223
232
  }
package/lib/runtime.js CHANGED
@@ -294,20 +294,24 @@ export class Runtime extends EventEmitter {
294
294
 
295
295
  const stopInvocations = []
296
296
 
297
- const allApplications = await this.getApplications(true)
298
-
299
297
  // Construct the reverse dependency graph
300
298
  const dependents = {}
301
- for (const application of allApplications.applications) {
302
- for (const dependency of application.dependencies ?? []) {
303
- let applicationDependents = dependents[dependency]
304
- if (!applicationDependents) {
305
- applicationDependents = new Set()
306
- dependents[dependency] = applicationDependents
307
- }
308
299
 
309
- applicationDependents.add(application.id)
300
+ try {
301
+ const allApplications = await this.getApplications(true)
302
+ for (const application of allApplications.applications) {
303
+ for (const dependency of application.dependencies ?? []) {
304
+ let applicationDependents = dependents[dependency]
305
+ if (!applicationDependents) {
306
+ applicationDependents = new Set()
307
+ dependents[dependency] = applicationDependents
308
+ }
309
+
310
+ applicationDependents.add(application.id)
311
+ }
310
312
  }
313
+ } catch (e) {
314
+ // Noop - This only happens if stop is invoked after a failed start, in which case we don't care about deps
311
315
  }
312
316
 
313
317
  for (const application of this.getApplicationsIds()) {
@@ -1606,17 +1610,12 @@ export class Runtime extends EventEmitter {
1606
1610
  if (enabled && config.restartOnError > 0) {
1607
1611
  // if gracePeriod is 0, it will be set to 1 to start health checks immediately
1608
1612
  // however, the health event will start when the worker is started
1609
- setTimeout(() => {
1610
- this.#setupHealthCheck(
1611
- config,
1612
- applicationConfig,
1613
- workersCount,
1614
- id,
1615
- index,
1616
- worker,
1617
- label
1618
- )
1619
- }, gracePeriod > 0 ? gracePeriod : 1).unref()
1613
+ setTimeout(
1614
+ () => {
1615
+ this.#setupHealthCheck(config, applicationConfig, workersCount, id, index, worker, label)
1616
+ },
1617
+ gracePeriod > 0 ? gracePeriod : 1
1618
+ ).unref()
1620
1619
  }
1621
1620
  } catch (err) {
1622
1621
  const error = ensureError(err)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "3.0.6",
3
+ "version": "3.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,14 +34,14 @@
34
34
  "typescript": "^5.5.4",
35
35
  "undici-oidc-interceptor": "^0.5.0",
36
36
  "why-is-node-running": "^2.2.2",
37
- "@platformatic/db": "3.0.6",
38
- "@platformatic/composer": "3.0.6",
39
- "@platformatic/gateway": "3.0.6",
40
- "@platformatic/service": "3.0.6",
41
- "@platformatic/sql-graphql": "3.0.6",
42
- "@platformatic/node": "3.0.6",
43
- "@platformatic/wattpm-pprof-capture": "3.0.6",
44
- "@platformatic/sql-mapper": "3.0.6"
37
+ "@platformatic/composer": "3.2.0",
38
+ "@platformatic/db": "3.2.0",
39
+ "@platformatic/gateway": "3.2.0",
40
+ "@platformatic/service": "3.2.0",
41
+ "@platformatic/sql-graphql": "3.2.0",
42
+ "@platformatic/node": "3.2.0",
43
+ "@platformatic/sql-mapper": "3.2.0",
44
+ "@platformatic/wattpm-pprof-capture": "3.2.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@fastify/accepts": "^5.0.0",
@@ -71,15 +71,15 @@
71
71
  "undici": "^7.0.0",
72
72
  "undici-thread-interceptor": "^0.14.0",
73
73
  "ws": "^8.16.0",
74
- "@platformatic/basic": "3.0.6",
75
- "@platformatic/generators": "3.0.6",
76
- "@platformatic/itc": "3.0.6",
77
- "@platformatic/foundation": "3.0.6",
78
- "@platformatic/metrics": "3.0.6",
79
- "@platformatic/telemetry": "3.0.6"
74
+ "@platformatic/basic": "3.2.0",
75
+ "@platformatic/foundation": "3.2.0",
76
+ "@platformatic/generators": "3.2.0",
77
+ "@platformatic/itc": "3.2.0",
78
+ "@platformatic/metrics": "3.2.0",
79
+ "@platformatic/telemetry": "3.2.0"
80
80
  },
81
81
  "engines": {
82
- "node": ">=22.18.0"
82
+ "node": ">=22.19.0"
83
83
  },
84
84
  "scripts": {
85
85
  "test": "npm run test:main && npm run test:api && npm run test:cli && npm run test:start && npm run test:multiple-workers",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.0.6.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.2.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -1665,8 +1665,19 @@
1665
1665
  }
1666
1666
  ]
1667
1667
  },
1668
- "additionalProperties": false
1669
- }
1668
+ "plugins": {
1669
+ "type": "array",
1670
+ "items": {
1671
+ "anyOf": [
1672
+ {
1673
+ "type": "string",
1674
+ "resolvePath": true
1675
+ }
1676
+ ]
1677
+ }
1678
+ }
1679
+ },
1680
+ "additionalProperties": false
1670
1681
  }
1671
1682
  ]
1672
1683
  },