@platformatic/basic 3.5.0 → 3.6.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
@@ -14,6 +14,7 @@ export interface PlatformaticBasicConfig {
14
14
  [k: string]: unknown;
15
15
  }[];
16
16
  workers?: number | string;
17
+ workersRestartDelay?: number | string;
17
18
  logger?: {
18
19
  level: (
19
20
  | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
package/lib/capability.js CHANGED
@@ -18,6 +18,7 @@ import pino from 'pino'
18
18
  import { NonZeroExitCode } from './errors.js'
19
19
  import { cleanBasePath } from './utils.js'
20
20
  import { ChildManager } from './worker/child-manager.js'
21
+
21
22
  const kITC = Symbol.for('plt.runtime.itc')
22
23
 
23
24
  export class BaseCapability extends EventEmitter {
@@ -188,7 +189,7 @@ export class BaseCapability extends EventEmitter {
188
189
 
189
190
  const { promise, resolve, reject } = Promise.withResolvers()
190
191
 
191
- function runtimeEventHandler ({ event, payload }) {
192
+ function runtimeEventHandler ({ event, payload: [payload] }) {
192
193
  if (event !== 'application:worker:started') {
193
194
  return
194
195
  }
@@ -247,7 +248,7 @@ export class BaseCapability extends EventEmitter {
247
248
 
248
249
  const { promise, resolve } = Promise.withResolvers()
249
250
 
250
- function runtimeEventHandler ({ event, payload }) {
251
+ function runtimeEventHandler ({ event, payload: [payload] }) {
251
252
  if (event !== 'application:worker:stopped') {
252
253
  return
253
254
  }
@@ -460,7 +461,7 @@ export class BaseCapability extends EventEmitter {
460
461
 
461
462
  this.childManager.on('event', event => {
462
463
  globalThis[kITC].notify('event', event)
463
- this.emit('application:worker:event', config)
464
+ this.emit('application:worker:event:' + event.event, event.payload)
464
465
  })
465
466
 
466
467
  // This is not really important for the URL but sometimes it also a sign
@@ -22,6 +22,13 @@ import { exitCodes } from '../errors.js'
22
22
  import { importFile } from '../utils.js'
23
23
  import { getSocketPath } from './child-manager.js'
24
24
 
25
+ class ForwardingEventEmitter extends EventEmitter {
26
+ emitAndNotify (event, ...args) {
27
+ globalThis.platformatic.itc.notify('event', { event, payload: args })
28
+ return super.emit(event, ...args)
29
+ }
30
+ }
31
+
25
32
  const windowsNpmExecutables = ['npm-prefix.js', 'npm-cli.js']
26
33
 
27
34
  function createInterceptor () {
@@ -480,7 +487,7 @@ async function main () {
480
487
  const { data, loader, scripts } = JSON.parse(await readFile(dataPath))
481
488
 
482
489
  globalThis.platformatic = data
483
- globalThis.platformatic.events = new EventEmitter()
490
+ globalThis.platformatic.events = new ForwardingEventEmitter()
484
491
 
485
492
  if (loader) {
486
493
  register(loader, { data })
@@ -490,7 +497,10 @@ async function main () {
490
497
  await importFile(script)
491
498
  }
492
499
 
493
- globalThis[Symbol.for('plt.children.itc')] = new ChildProcess()
500
+ const childProcess = new ChildProcess()
501
+ globalThis[Symbol.for('plt.children.itc')] = childProcess
502
+ globalThis.platformatic.itc = childProcess
503
+ globalThis.platformatic.events.target = childProcess
494
504
  }
495
505
 
496
506
  await main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -25,10 +25,10 @@
25
25
  "split2": "^4.2.0",
26
26
  "undici": "^7.0.0",
27
27
  "ws": "^8.18.0",
28
- "@platformatic/foundation": "3.5.0",
29
- "@platformatic/itc": "3.5.0",
30
- "@platformatic/metrics": "3.5.0",
31
- "@platformatic/telemetry": "3.5.0"
28
+ "@platformatic/itc": "3.6.0",
29
+ "@platformatic/foundation": "3.6.0",
30
+ "@platformatic/metrics": "3.6.0",
31
+ "@platformatic/telemetry": "3.6.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "cleaner-spec-reporter": "^0.5.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.5.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/3.6.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Basic Config",
5
5
  "type": "object",
@@ -276,6 +276,18 @@
276
276
  ],
277
277
  "default": 1
278
278
  },
279
+ "workersRestartDelay": {
280
+ "anyOf": [
281
+ {
282
+ "type": "number",
283
+ "minimum": 0
284
+ },
285
+ {
286
+ "type": "string"
287
+ }
288
+ ],
289
+ "default": 0
290
+ },
279
291
  "logger": {
280
292
  "type": "object",
281
293
  "properties": {