-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathecosystem.config.cjs
More file actions
50 lines (46 loc) · 1.22 KB
/
ecosystem.config.cjs
File metadata and controls
50 lines (46 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const fs = require("fs");
const path = require("path");
function readEnvFile(filename) {
const filePath = path.join(__dirname, filename);
if (!fs.existsSync(filePath)) return {};
return Object.fromEntries(
fs
.readFileSync(filePath, "utf8")
.split(/\r?\n/)
.map(line => line.trim())
.filter(line => line && !line.startsWith("#"))
.map(line => {
const separator = line.indexOf("=");
if (separator === -1) return null;
const key = line.slice(0, separator).trim();
const value = line
.slice(separator + 1)
.trim()
.replace(/^(['"])(.*)\1$/, "$2");
return [key, value];
})
.filter(Boolean)
);
}
const productionEnv = readEnvFile(".env.production");
module.exports = {
apps: [
{
name: "xss-platform",
script: "./dist/index.js",
interpreter: "node",
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: "512M",
env: {
...productionEnv,
NODE_ENV: "production",
PORT: productionEnv.PORT || "3100",
},
error_file: "./logs/error.log",
out_file: "./logs/out.log",
log_date_format: "YYYY-MM-DD HH:mm:ss",
},
],
};