/** * ───────────────────────────────────────────── * SPB Drive — Personal Cloud Drive * ───────────────────────────────────────────── * Author : Simon-Pierre Boucher * Contact : contact@spboucher.ai * File : deploy/ecosystem.config.cjs * Purpose : pm2 process definitions — server + ngrok tunnel * License : MIT © Simon-Pierre Boucher * ───────────────────────────────────────────── */ const os = require('node:os'); // macOS seals /srv — the drive lives under $HOME/srv (see setup-m3u96b.sh). const DATA_DIR = `${os.homedir()}/srv/drive`; const APP_DIR = `${DATA_DIR}/app`; const LOG_DIR = `${DATA_DIR}/logs`; // The authtoken lives in the agent's default config (ngrok config add-authtoken); // both configs are passed and merged in order — v3 configs don't expand env vars. const NGROK_AGENT_CFG = `${os.homedir()}/Library/Application Support/ngrok/ngrok.yml`; module.exports = { apps: [ { name: 'spbdrive-server', cwd: APP_DIR, script: 'src/server.mjs', interpreter: 'node', env: { NODE_ENV: 'production', SPBDRIVE_DATA_DIR: DATA_DIR, SPBDRIVE_PORT: '7430', SPBDRIVE_HOST: '127.0.0.1', SPBDRIVE_PUBLIC_URL: 'https://drive.spboucher.ai', SPBDRIVE_TRUST_PROXY: 'true', }, autorestart: true, max_restarts: 50, restart_delay: 3000, out_file: `${LOG_DIR}/server.out.log`, error_file: `${LOG_DIR}/server.err.log`, merge_logs: true, time: true, }, { name: 'spbdrive-tunnel', cwd: APP_DIR, script: 'ngrok', args: ['start', 'spbdrive', '--config', NGROK_AGENT_CFG, '--config', `${APP_DIR}/deploy/ngrok.yml`], interpreter: 'none', autorestart: true, restart_delay: 5000, out_file: `${LOG_DIR}/tunnel.out.log`, error_file: `${LOG_DIR}/tunnel.err.log`, merge_logs: true, time: true, }, ], };