const fs = require('fs'); const path = require('path'); function parseEnvFile(file) { const out = {}; if (!fs.existsSync(file)) return out; for (const raw of fs.readFileSync(file, 'utf8').split(/\r?\n/)) { const line = raw.trim(); if (!line || line.startsWith('#')) continue; const eq = line.indexOf('='); if (eq < 1) continue; const key = line.slice(0, eq).trim(); let val = line.slice(eq + 1).trim(); if ( (val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'")) ) { val = val.slice(1, -1); } out[key] = val; } return out; } const secretEnv = { ...parseEnvFile(path.join(__dirname, 'nowpayments.env')), ...parseEnvFile(path.join(__dirname, '..', '.env')), }; module.exports = { apps: [ { name: 'ebook', script: 'server.js', cwd: '/var/www/ebook/.next/standalone', instances: 1, exec_mode: 'fork', autorestart: true, watch: false, max_memory_restart: '512M', env: { NODE_ENV: 'production', PORT: 3022, HOSTNAME: '0.0.0.0', NEXT_PUBLIC_SITE_URL: 'https://book.nomadro.com', NEXT_PUBLIC_SHARE_CAMPAIGN: 'nomad-code', ...secretEnv, }, }, ], };