Files
AeroMc-Launcher/server/curseforge-proxy/ecosystem.config.js
2026-08-02 17:01:18 +02:00

55 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
/*
* pm2-Konfiguration für die CurseForge-Weiterleitung.
*
* pm2 start ecosystem.config.js
* pm2 save
*
* pm2 liest .env-Dateien nicht von selbst, deshalb tut es diese Datei.
* So bleibt der Schlüssel in der .env und steht nicht in der Konfiguration,
* die man eher mal weitergibt oder eincheckt.
*/
const fs = require('fs');
const path = require('path');
// kleiner .env-Leser Kommentare, Anführungszeichen und Werte mit "=" inklusive
function leseEnv(datei) {
const werte = {};
if (!fs.existsSync(datei)) return werte;
for (const zeile of fs.readFileSync(datei, 'utf8').split(/\r?\n/)) {
const t = zeile.trim();
if (!t || t.startsWith('#')) continue;
const i = t.indexOf('=');
if (i < 1) continue;
const name = t.slice(0, i).trim();
let wert = t.slice(i + 1).trim();
const q = wert[0];
if ((q === '"' || q === "'") && wert.endsWith(q) && wert.length > 1) wert = wert.slice(1, -1);
werte[name] = wert;
}
return werte;
}
module.exports = {
apps: [{
name: 'aeromc-cf-proxy',
script: 'index.js',
cwd: __dirname,
// Fork-Betrieb mit genau einem Prozess. Im Cluster-Betrieb hätte jeder
// Arbeiter seine eigene Zählung die Ratenbegrenzung wäre dann bei
// vier Prozessen viermal so hoch wie eingestellt.
exec_mode: 'fork',
instances: 1,
autorestart: true,
max_restarts: 10,
restart_delay: 3000,
max_memory_restart: '256M',
env: leseEnv(path.join(__dirname, '.env')),
}],
};