@platformatic/runtime 2.45.0 → 2.47.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
@@ -5,7 +5,7 @@
5
5
  * and run json-schema-to-typescript to regenerate this file.
6
6
  */
7
7
 
8
- export type HttpsSchemasPlatformaticDevPlatformaticRuntime2450Json = {
8
+ export type HttpsSchemasPlatformaticDevPlatformaticRuntime2470Json = {
9
9
  [k: string]: unknown;
10
10
  } & {
11
11
  $schema?: string;
package/lib/runtime.js CHANGED
@@ -274,11 +274,23 @@ class Runtime extends EventEmitter {
274
274
  if (this.#inspectorServer) {
275
275
  await this.#inspectorServer.close()
276
276
  }
277
- await this.#meshInterceptor.close()
278
- for (const service of this.#servicesIds) {
277
+
278
+ // Stop the entrypoint first so that no new requests are accepted
279
+ if (this.#entrypointId) {
280
+ await this.stopService(this.#entrypointId, silent)
281
+ }
282
+
283
+ // Stop services in reverse order to ensure services which depend on others are stopped first
284
+ for (const service of this.#servicesIds.reverse()) {
285
+ // The entrypoint has been stopped above
286
+ if (service === this.#entrypointId) {
287
+ continue
288
+ }
289
+
279
290
  await this.stopService(service, silent)
280
291
  }
281
292
 
293
+ await this.#meshInterceptor.close()
282
294
  this.#updateStatus('stopped')
283
295
  }
284
296
 
@@ -1131,7 +1143,7 @@ class Runtime extends EventEmitter {
1131
1143
  worker[kFullId] = workerId
1132
1144
  worker[kServiceId] = serviceId
1133
1145
  worker[kWorkerId] = workersCount > 1 ? index : undefined
1134
- worker[kWorkerStatus] = 'init'
1146
+ worker[kWorkerStatus] = 'boot'
1135
1147
  worker[kForwardEvents] = false
1136
1148
 
1137
1149
  if (inspectorOptions) {
@@ -1214,8 +1226,8 @@ class Runtime extends EventEmitter {
1214
1226
 
1215
1227
  // This must be done here as the dependencies are filled above
1216
1228
  worker[kConfig] = { ...serviceConfig, health }
1217
- worker[kWorkerStatus] = 'boot'
1218
- this.emit('service:worker:boot', eventPayload)
1229
+ worker[kWorkerStatus] = 'init'
1230
+ this.emit('service:worker:init', eventPayload)
1219
1231
 
1220
1232
  return worker
1221
1233
  }
@@ -1405,8 +1417,8 @@ class Runtime extends EventEmitter {
1405
1417
  return
1406
1418
  }
1407
1419
 
1408
- // Starting should be aborted, discard the worker
1409
- if (worker[kWorkerStatus] !== 'started') {
1420
+ // Boot should be aborted, discard the worker
1421
+ if (worker[kWorkerStatus] === 'boot') {
1410
1422
  return this.#discardWorker(worker)
1411
1423
  }
1412
1424
 
@@ -1466,6 +1478,7 @@ class Runtime extends EventEmitter {
1466
1478
  }
1467
1479
 
1468
1480
  async #discardWorker (worker) {
1481
+ this.#meshInterceptor.unroute(worker[kServiceId], worker, true)
1469
1482
  worker.removeAllListeners('exit')
1470
1483
  await worker.terminate()
1471
1484
 
package/lib/worker/itc.js CHANGED
@@ -86,7 +86,7 @@ function setupITC (app, service, dispatcher) {
86
86
  await once(app, 'start')
87
87
  }
88
88
 
89
- if (status !== 'stopped') {
89
+ if (status.startsWith('start')) {
90
90
  // This gives a chance to a stackable to perform custom logic
91
91
  globalThis.platformatic.events.emit('stop')
92
92
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "2.45.0",
3
+ "version": "2.47.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -37,12 +37,12 @@
37
37
  "typescript": "^5.5.4",
38
38
  "undici-oidc-interceptor": "^0.5.0",
39
39
  "why-is-node-running": "^2.2.2",
40
- "@platformatic/composer": "2.45.0",
41
- "@platformatic/db": "2.45.0",
42
- "@platformatic/service": "2.45.0",
43
- "@platformatic/node": "2.45.0",
44
- "@platformatic/sql-graphql": "2.45.0",
45
- "@platformatic/sql-mapper": "2.45.0"
40
+ "@platformatic/composer": "2.47.0",
41
+ "@platformatic/db": "2.47.0",
42
+ "@platformatic/node": "2.47.0",
43
+ "@platformatic/service": "2.47.0",
44
+ "@platformatic/sql-mapper": "2.47.0",
45
+ "@platformatic/sql-graphql": "2.47.0"
46
46
  },
47
47
  "dependencies": {
48
48
  "@fastify/accepts": "^5.0.0",
@@ -74,15 +74,15 @@
74
74
  "tail-file-stream": "^0.2.0",
75
75
  "thread-cpu-usage": "^0.2.0",
76
76
  "undici": "^7.0.0",
77
- "undici-thread-interceptor": "^0.12.2",
77
+ "undici-thread-interceptor": "^0.13.1",
78
78
  "ws": "^8.16.0",
79
- "@platformatic/basic": "2.45.0",
80
- "@platformatic/generators": "2.45.0",
81
- "@platformatic/config": "2.45.0",
82
- "@platformatic/itc": "2.45.0",
83
- "@platformatic/ts-compiler": "2.45.0",
84
- "@platformatic/telemetry": "2.45.0",
85
- "@platformatic/utils": "2.45.0"
79
+ "@platformatic/basic": "2.47.0",
80
+ "@platformatic/generators": "2.47.0",
81
+ "@platformatic/config": "2.47.0",
82
+ "@platformatic/itc": "2.47.0",
83
+ "@platformatic/ts-compiler": "2.47.0",
84
+ "@platformatic/telemetry": "2.47.0",
85
+ "@platformatic/utils": "2.47.0"
86
86
  },
87
87
  "scripts": {
88
88
  "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.45.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/runtime/2.47.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {