@platformatic/watt-extra 1.13.0-alpha.3 → 1.13.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/lib/watt.js CHANGED
@@ -53,15 +53,11 @@ class Watt {
53
53
  }
54
54
 
55
55
  async spawn () {
56
- this.#logger.info('[ECS-DEBUG] spawn: enter')
57
56
  try {
58
57
  this.runtime = await this.#createRuntime()
59
- this.#logger.info('[ECS-DEBUG] spawn: createRuntime returned, about to call runtime.start()')
60
58
  this.#logger.info('Starting runtime -WATT')
61
59
  await this.runtime.start()
62
- this.#logger.info('[ECS-DEBUG] spawn: runtime.start() returned')
63
60
  await this.updateSharedContext(this.#sharedContext)
64
- this.#logger.info('[ECS-DEBUG] spawn: updateSharedContext returned')
65
61
  this.#logger.info('Runtime started')
66
62
  } catch (err) {
67
63
  this.#logger.error(
@@ -159,17 +155,14 @@ class Watt {
159
155
  }
160
156
 
161
157
  async #createRuntime () {
162
- this.#logger.info('[ECS-DEBUG] createRuntime: enter')
163
158
  this.#logger.info('Creating runtime')
164
159
  const { create, transform } = this.#require('@platformatic/runtime')
165
160
 
166
- this.#logger.info('[ECS-DEBUG] createRuntime: about to call platformatic create()')
167
161
  this.#logger.info('Creating runtime')
168
162
 
169
163
  const runtime = await create(this.#appDir, null, {
170
164
  isProduction: true,
171
165
  transform: async (config) => {
172
- this.#logger.info('[ECS-DEBUG] createRuntime: transform called')
173
166
  config = await transform(config)
174
167
 
175
168
  this.#config = config
@@ -178,11 +171,9 @@ class Watt {
178
171
  this.#logger.info('Patching runtime config')
179
172
 
180
173
  this.#patchRuntimeConfig(config)
181
- this.#logger.info('[ECS-DEBUG] createRuntime: transform done')
182
174
  return config
183
175
  }
184
176
  })
185
- this.#logger.info('[ECS-DEBUG] createRuntime: platformatic create() returned')
186
177
 
187
178
  /* c8 ignore next 3 */
188
179
  const restartListener = restartRuntime.bind(null, runtime)
@@ -191,15 +182,11 @@ class Watt {
191
182
  process.removeListener('SIGUSR2', restartListener)
192
183
  })
193
184
 
194
- this.#logger.info('[ECS-DEBUG] createRuntime: about to configureServices')
195
185
  await this.#configureServices(runtime)
196
- this.#logger.info('[ECS-DEBUG] createRuntime: configureServices returned, about to runtime.init()')
197
186
 
198
187
  try {
199
188
  await runtime.init()
200
- this.#logger.info('[ECS-DEBUG] createRuntime: runtime.init() returned')
201
189
  } catch (e) {
202
- this.#logger.error({ err: ensureLoggableError(e) }, '[ECS-DEBUG] createRuntime: runtime.init() threw')
203
190
  await runtime.close()
204
191
  throw e
205
192
  }
@@ -521,18 +508,13 @@ class Watt {
521
508
  }
522
509
 
523
510
  async #configureServices (runtime) {
524
- this.#logger.info('[ECS-DEBUG] configureServices: enter')
525
511
  if (typeof runtime.setApplicationConfigPatch !== 'function') {
526
- this.#logger.info('[ECS-DEBUG] configureServices: runtime has no setApplicationConfigPatch, skipping')
527
512
  return
528
513
  }
529
514
 
530
515
  const config = runtime.getRuntimeConfig(true)
531
- const apps = config.applications ?? []
532
- this.#logger.info({ count: apps.length, apps: apps.map(a => ({ id: a.id, type: a.type, entrypoint: a.entrypoint })) }, '[ECS-DEBUG] configureServices: iterating apps')
533
516
 
534
- for (const app of apps) {
535
- this.#logger.info({ id: app.id, type: app.type }, '[ECS-DEBUG] configureServices: handling app')
517
+ for (const app of config.applications ?? []) {
536
518
  if (app.type === 'next') {
537
519
  await this.#configureNextService(runtime, app)
538
520
  } else if (
@@ -546,24 +528,19 @@ class Watt {
546
528
  } else if (app.type === '@platformatic/regina') {
547
529
  await this.#configureReginaService(runtime, app)
548
530
  }
549
- this.#logger.info({ id: app.id }, '[ECS-DEBUG] configureServices: done with app')
550
531
  }
551
- this.#logger.info('[ECS-DEBUG] configureServices: all apps configured')
552
532
  }
553
533
 
554
534
  async #configureNextService (runtime, service) {
555
- this.#logger.info({ id: service.id, path: service.path, entrypoint: service.entrypoint }, '[ECS-DEBUG] configureNextService: enter')
556
535
  let nextSchema
557
536
 
558
537
  try {
559
538
  const nextPackage = createRequire(
560
539
  resolve(service.path, 'index.js')
561
540
  ).resolve('@platformatic/next')
562
- this.#logger.info({ nextPackage }, '[ECS-DEBUG] configureNextService: resolved @platformatic/next')
563
541
  nextSchema = JSON.parse(
564
542
  await readFile(resolve(nextPackage, '../schema.json'), 'utf8')
565
543
  )
566
- this.#logger.info('[ECS-DEBUG] configureNextService: read next schema')
567
544
  } catch (e) {
568
545
  this.#logger.error(
569
546
  { err: ensureLoggableError(e) },
@@ -612,7 +589,6 @@ class Watt {
612
589
  }
613
590
 
614
591
  async #configurePlatformaticServices (runtime, app) {
615
- this.#logger.info({ id: app.id, entrypoint: app.entrypoint, type: app.type }, '[ECS-DEBUG] configurePlatformaticServices: enter')
616
592
  if (app.entrypoint) {
617
593
  const config = app
618
594
  const patches = [{ op: 'add', path: '/server/trustProxy', value: true }]
@@ -625,27 +601,20 @@ class Watt {
625
601
 
626
602
  this.#patchService(runtime, app.id, patches)
627
603
  }
628
- this.#logger.info({ id: app.id }, '[ECS-DEBUG] configurePlatformaticServices: exit')
629
604
  }
630
605
 
631
606
  async #configureReginaService (runtime, app) {
632
- this.#logger.info({ id: app.id }, '[ECS-DEBUG] configureReginaService: enter')
633
607
  const privateIp = await this.#getPrivateIp()
634
608
  const port = this.#getRuntimePort()
635
609
  const address = `http://${privateIp}:${port}`
636
- this.#logger.info({ id: app.id, address }, '[ECS-DEBUG] configureReginaService: applying patch')
637
610
 
638
611
  this.#patchService(runtime, app.id, [
639
612
  { op: 'add', path: '/regina/memberAddress', value: address }
640
613
  ])
641
- this.#logger.info({ id: app.id }, '[ECS-DEBUG] configureReginaService: exit')
642
614
  }
643
615
 
644
616
  async #getPrivateIp () {
645
- const hostname = os.hostname()
646
- this.#logger.info({ hostname }, '[ECS-DEBUG] getPrivateIp: about to dns.lookup')
647
- const { address } = await dns.lookup(hostname)
648
- this.#logger.info({ hostname, address }, '[ECS-DEBUG] getPrivateIp: resolved')
617
+ const { address } = await dns.lookup(os.hostname())
649
618
  return address
650
619
  }
651
620
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.13.0-alpha.3",
3
+ "version": "1.13.0",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
package/plugins/auth.js CHANGED
@@ -43,13 +43,10 @@ async function loadK8sToken (log) {
43
43
  // endpoint. K8s identity travels via the SA JWT, so no resolution needed there.
44
44
  async function resolveEcsIdentity (log) {
45
45
  const metadataUrl = `${process.env.ECS_CONTAINER_METADATA_URI_V4}/task`
46
- log.info({ metadataUrl }, '[ECS-DEBUG] resolveEcsIdentity: fetching task metadata')
47
46
  try {
48
47
  const res = await fetch(metadataUrl)
49
- log.info({ status: res.status, ok: res.ok }, '[ECS-DEBUG] resolveEcsIdentity: metadata fetch returned')
50
48
  if (!res.ok) throw new Error(`status ${res.status}`)
51
49
  const meta = await res.json()
52
- log.info({ TaskARN: meta.TaskARN, Cluster: meta.Cluster, Family: meta.Family, LaunchType: meta.LaunchType }, '[ECS-DEBUG] resolveEcsIdentity: parsed metadata')
53
50
  const id = meta.TaskARN?.split('/').pop()
54
51
  // meta.Cluster may be either the short name or the full cluster ARN
55
52
  // (e.g. 'arn:aws:ecs:us-east-1:123456789012:cluster/my-cluster'). We
package/plugins/init.js CHANGED
@@ -26,14 +26,6 @@ async function initPlugin (app) {
26
26
  const applicationDir = app.env.PLT_APP_DIR
27
27
  const instanceId = app.provider === 'k8s' ? os.hostname() : app.machineIdentity?.id
28
28
 
29
- app.log.info({
30
- provider: app.provider,
31
- hostname: os.hostname(),
32
- machineIdentity: app.machineIdentity,
33
- instanceId,
34
- applicationDir
35
- }, '[ECS-DEBUG] init: computed instanceId')
36
-
37
29
  app.log.info({ applicationName, applicationDir }, 'Loading watt-extra application')
38
30
 
39
31
  // Skip ICC initialization if PLT_ICC_URL is not set
@@ -47,14 +39,6 @@ async function initPlugin (app) {
47
39
 
48
40
  const instanceConfig = await initApplicationInstance(instanceId, applicationName)
49
41
  app.log.info({ applicationId: instanceConfig.applicationId }, 'Got application info')
50
- app.log.info({
51
- iccServices: instanceConfig.iccServices,
52
- enableSlicerInterceptor: instanceConfig.enableSlicerInterceptor,
53
- enableTrafficInterceptor: instanceConfig.enableTrafficInterceptor,
54
- enableOpenTelemetry: instanceConfig.enableOpenTelemetry,
55
- httpCacheKeys: Object.keys(instanceConfig.httpCache?.clientOpts || {}),
56
- configKeys: Object.keys(instanceConfig.config || {})
57
- }, '[ECS-DEBUG] init: ICC instanceConfig details')
58
42
 
59
43
  instanceConfig.scaler ??= { version: 'v1' }
60
44