@platformatic/watt-extra 1.12.0-alpha.0 → 1.12.0-alpha.2
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 +60 -1
- package/package.json +1 -1
- package/plugins/env.js +1 -0
- package/plugins/init.js +0 -1
package/lib/watt.js
CHANGED
|
@@ -513,7 +513,6 @@ class Watt {
|
|
|
513
513
|
const config = runtime.getRuntimeConfig(true)
|
|
514
514
|
|
|
515
515
|
for (const app of config.applications ?? []) {
|
|
516
|
-
process._rawDebug('--------APP TYPE--------', app.type, this.#instanceConfig)
|
|
517
516
|
if (app.type === 'next') {
|
|
518
517
|
await this.#configureNextService(runtime, app)
|
|
519
518
|
} else if (
|
|
@@ -525,6 +524,10 @@ class Watt {
|
|
|
525
524
|
) {
|
|
526
525
|
await this.#configurePlatformaticServices(runtime, app)
|
|
527
526
|
}
|
|
527
|
+
// else if (app.type === '@platformatic/regina') {
|
|
528
|
+
// this.#configureReginaService(runtime, app)
|
|
529
|
+
// }
|
|
530
|
+
this.#configureReginaService(runtime, app)
|
|
528
531
|
}
|
|
529
532
|
}
|
|
530
533
|
|
|
@@ -600,6 +603,62 @@ class Watt {
|
|
|
600
603
|
}
|
|
601
604
|
}
|
|
602
605
|
|
|
606
|
+
#configureReginaService (runtime, app) {
|
|
607
|
+
process._rawDebug('--------INS CONFIG--------', this.#instanceConfig)
|
|
608
|
+
|
|
609
|
+
const privateIp = this.#instanceConfig?.podDetails?.privateIp
|
|
610
|
+
const port = this.#getContainerHttpPort()
|
|
611
|
+
|
|
612
|
+
if (!privateIp) {
|
|
613
|
+
this.#logger.warn('Missing private IP address, not setting up Regina member address')
|
|
614
|
+
return
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const address = `http://${privateIp}:${port}`
|
|
618
|
+
process._rawDebug('--------ADDRESS--------', address)
|
|
619
|
+
|
|
620
|
+
// const patches = [
|
|
621
|
+
// { op: 'add', path: '/regina/memberAddress', value: address },
|
|
622
|
+
// ]
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
#getContainerHttpPort () {
|
|
626
|
+
const defaultPort = this.#env.PLT_DEFAULT_CONTAINER_PORT
|
|
627
|
+
|
|
628
|
+
let ports = this.#instanceConfig?.podDetails?.ports
|
|
629
|
+
if (!Array.isArray(ports) || ports.length === 0) {
|
|
630
|
+
return defaultPort
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
ports = ports.filter((port) => port.protocol === 'TCP')
|
|
634
|
+
if (ports.length === 0) {
|
|
635
|
+
return defaultPort
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (ports.length === 1) {
|
|
639
|
+
return ports[0].containerPort
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
const httpPort = ports.find((port) => port.name === 'http')
|
|
643
|
+
if (httpPort) {
|
|
644
|
+
return httpPort.containerPort
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const metricPorts = [9090]
|
|
648
|
+
ports = ports.filter((port) => !metricPorts.includes(port.containerPort))
|
|
649
|
+
|
|
650
|
+
if (ports.length === 1) {
|
|
651
|
+
return ports[0].containerPort
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
this.#logger.warn(
|
|
655
|
+
{ ports: this.#instanceConfig.ports, defaultPort },
|
|
656
|
+
'Multiple ports found, cannot determine the HTTP port, using default'
|
|
657
|
+
)
|
|
658
|
+
|
|
659
|
+
return defaultPort
|
|
660
|
+
}
|
|
661
|
+
|
|
603
662
|
async #patchService (runtime, id, patches) {
|
|
604
663
|
this.#logger.info({ patches }, `Applying patches to service ${id} ...`)
|
|
605
664
|
runtime.setApplicationConfigPatch(id, patches)
|
package/package.json
CHANGED
package/plugins/env.js
CHANGED
|
@@ -32,6 +32,7 @@ const schema = {
|
|
|
32
32
|
PLT_HEALTH_SIGNALS_LONG_BATCH_TIMEOUT: { type: 'number', default: 30000 },
|
|
33
33
|
PLT_HEALTH_SIGNALS_ELU_BATCH_THRESHOLD: { type: 'number', default: 0.5 },
|
|
34
34
|
PLT_HEALTH_SIGNALS_HEAP_BATCH_THRESHOLD: { type: ['number', 'string'], default: '300MB' },
|
|
35
|
+
PLT_DEFAULT_CONTAINER_PORT: { type: 'number', default: 8080 }
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
|
package/plugins/init.js
CHANGED
|
@@ -38,7 +38,6 @@ async function initPlugin (app) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const instanceConfig = await initApplicationInstance(instanceId, applicationName)
|
|
41
|
-
process._rawDebug('--------INIT APP CONFIG--------', instanceConfig)
|
|
42
41
|
app.log.info({ applicationId: instanceConfig.applicationId }, 'Got application info')
|
|
43
42
|
|
|
44
43
|
instanceConfig.scaler ??= { version: 'v1' }
|