pwi-plata-type 0.2.9 → 0.2.10
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/bin/plata.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { PlataClusterManager, PlataClusterMsg } from "../libs/cluster.js"
|
|
|
2
2
|
import { loadEnvProjectFile } from "../libs/env.js"
|
|
3
3
|
import { loadExpressRoutes } from "../libs/routes.js"
|
|
4
4
|
import express, { Express } from "express"
|
|
5
|
+
import { createServer } from 'node:https'
|
|
6
|
+
import fs from 'node:fs'
|
|
7
|
+
import { PlataDirs } from "../libs/tools.js"
|
|
8
|
+
import path from 'node:path'
|
|
5
9
|
|
|
6
10
|
const main = async () => {
|
|
7
11
|
const clusterLib = new PlataClusterManager();
|
|
@@ -70,10 +74,37 @@ const main = async () => {
|
|
|
70
74
|
})
|
|
71
75
|
})
|
|
72
76
|
|
|
73
|
-
|
|
74
|
-
console.log(`
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (!process.env._PLATA_API_SSL_KEY || !process.env._PLATA_API_SSL_CERT) {
|
|
78
|
+
console.log(`Nenhum certificado configurado na env ${process.env.ENV}:`)
|
|
79
|
+
console.log(`_PLATA_API_SSL_KEY: ${process.env._PLATA_API_SSL_KEY}`)
|
|
80
|
+
console.log(`_PLATA_API_SSL_CERT: ${process.env._PLATA_API_SSL_CERT}`)
|
|
81
|
+
|
|
82
|
+
app.listen(port, () => {
|
|
83
|
+
console.log(`Iniciando Worker Express na porta ${port}`)
|
|
84
|
+
setTimeout(() => process.removeAllListeners('exit'), 500)
|
|
85
|
+
})
|
|
86
|
+
} else {
|
|
87
|
+
console.log('Iniciando a Plata com ssl usando os arquivos:')
|
|
88
|
+
console.log(`key: ${process.env._PLATA_API_SSL_KEY}`)
|
|
89
|
+
console.log(`cert: ${process.env._PLATA_API_SSL_CERT}`)
|
|
90
|
+
|
|
91
|
+
const https = createServer({
|
|
92
|
+
cert: fs.readdirSync(path.normalize(path.join(
|
|
93
|
+
PlataDirs.getProjectDir(),
|
|
94
|
+
process.env._PLATA_API_SSL_CERT
|
|
95
|
+
))),
|
|
96
|
+
key: fs.readdirSync(path.normalize(path.join(
|
|
97
|
+
PlataDirs.getProjectDir(),
|
|
98
|
+
process.env._PLATA_API_SSL_KEY
|
|
99
|
+
)))
|
|
100
|
+
}, app)
|
|
101
|
+
|
|
102
|
+
https.listen(port, () => {
|
|
103
|
+
console.log(`Iniciando Worker Express na porta ${port} com SSL`)
|
|
104
|
+
setTimeout(() => process.removeAllListeners('exit'), 500)
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
77
108
|
} else {
|
|
78
109
|
await clusterLib.loadWorker()
|
|
79
110
|
}
|
package/package.json
CHANGED