Files
gamer/ecosystem.config.js
T

38 lines
983 B
JavaScript
Raw Normal View History

2026-07-01 16:13:47 +08:00
const fs = require('fs');
const path = require('path');
function loadEnvFile(filePath) {
if (!fs.existsSync(filePath)) return {};
return fs.readFileSync(filePath, 'utf8')
.split(/\r?\n/)
.reduce((env, line) => {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) return env;
const idx = trimmed.indexOf('=');
if (idx === -1) return env;
const key = trimmed.slice(0, idx).trim();
const value = trimmed.slice(idx + 1).trim();
env[key] = value.replace(/^['"]|['"]$/g, '');
return env;
}, {});
}
const runtimeEnv = loadEnvFile(path.join(__dirname, '.env'));
2026-03-12 11:23:10 +08:00
module.exports = {
apps: [{
name: 'gamer',
script: 'server/app.js',
env: {
2026-07-01 16:13:47 +08:00
...runtimeEnv,
2026-03-12 11:23:10 +08:00
NODE_ENV: 'production',
2026-07-12 17:50:04 +08:00
PORT: 3000,
HOST: runtimeEnv.HOST || '0.0.0.0',
TRUST_PROXY: runtimeEnv.TRUST_PROXY || 'loopback'
2026-03-12 11:23:10 +08:00
},
instances: 1,
autorestart: true,
max_memory_restart: '200M'
}]
};