@platformatic/watt-extra 1.12.0-alpha.2 → 1.12.0-alpha.4
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 +14 -38
- package/package.json +1 -1
- package/plugins/env.js +0 -1
package/lib/watt.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import os from 'node:os'
|
|
2
|
+
import dns from 'node:dns/promises'
|
|
1
3
|
import { readFile } from 'node:fs/promises'
|
|
2
4
|
import { join, resolve } from 'node:path'
|
|
3
5
|
import { createRequire } from 'node:module'
|
|
@@ -603,11 +605,11 @@ class Watt {
|
|
|
603
605
|
}
|
|
604
606
|
}
|
|
605
607
|
|
|
606
|
-
#configureReginaService (runtime, app) {
|
|
607
|
-
process._rawDebug('--------
|
|
608
|
+
async #configureReginaService (runtime, app) {
|
|
609
|
+
process._rawDebug('--------INSTANCE CONFIG--------', this.#instanceConfig)
|
|
608
610
|
|
|
609
|
-
const privateIp = this.#
|
|
610
|
-
const port = this.#
|
|
611
|
+
const privateIp = await this.#getPrivateIp()
|
|
612
|
+
const port = this.#getRuntimePort()
|
|
611
613
|
|
|
612
614
|
if (!privateIp) {
|
|
613
615
|
this.#logger.warn('Missing private IP address, not setting up Regina member address')
|
|
@@ -622,41 +624,15 @@ class Watt {
|
|
|
622
624
|
// ]
|
|
623
625
|
}
|
|
624
626
|
|
|
625
|
-
#
|
|
626
|
-
const
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
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
|
-
)
|
|
627
|
+
async #getPrivateIp () {
|
|
628
|
+
const { address } = await dns.lookup(os.hostname())
|
|
629
|
+
process._rawDebug('--------IP--------', address)
|
|
630
|
+
return address
|
|
631
|
+
}
|
|
658
632
|
|
|
659
|
-
|
|
633
|
+
#getRuntimePort () {
|
|
634
|
+
const runtimeConfg = this.#config
|
|
635
|
+
return this.#env.PLT_APP_PORT || runtimeConfg.server.port
|
|
660
636
|
}
|
|
661
637
|
|
|
662
638
|
async #patchService (runtime, id, patches) {
|
package/package.json
CHANGED
package/plugins/env.js
CHANGED
|
@@ -32,7 +32,6 @@ 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 }
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|