SPB Git

spb/spbgit Public MIT

SPB Git — the platform hosting itself

JavaScript 73.9% CSS 11.7% Nunjucks 11.6% Shell 2.7%
2.2 KB · 60 lines javascript
Raw Blame History
1/**2 * ─────────────────────────────────────────────3 *  SPB Git — Personal Git Platform4 * ─────────────────────────────────────────────5 *  Author  : Simon-Pierre Boucher6 *  Contact : contact@spboucher.ai7 *  File    : deploy/ecosystem.config.cjs8 *  Purpose : pm2 process definitions — server + ngrok tunnel9 *  License : MIT © Simon-Pierre Boucher10 * ─────────────────────────────────────────────11 *12 * Usage on m3u96a:13 *   pm2 start deploy/ecosystem.config.cjs14 *   pm2 save && pm2 startup     # survive reboots15 */1617const path = require('node:path');18const APP_DIR = path.resolve(__dirname, '..');19const LOG_DIR = process.env.SPBGIT_LOG_DIR || path.join(process.env.HOME || '/tmp', 'srv/spbgit/logs');2021module.exports = {22  apps: [23    {24      name: 'spbgit-server',25      cwd: APP_DIR,26      script: 'src/server.mjs',27      interpreter: 'node',28      autorestart: true,29      max_restarts: 25,30      restart_delay: 2000,31      max_memory_restart: '750M',32      out_file: path.join(LOG_DIR, 'server-out.log'),33      error_file: path.join(LOG_DIR, 'server-err.log'),34      merge_logs: true,35      time: true,36      env: {37        NODE_ENV: 'production',38      },39    },40    {41      name: 'spbgit-tunnel',42      cwd: APP_DIR,43      script: 'ngrok',44      // SPBGIT_NGROK_CONFIG lets the host point at a resolved config that45      // carries the real authtoken (deploy/ngrok.yml is the tracked template).46      args: `start --config ${process.env.SPBGIT_NGROK_CONFIG || 'deploy/ngrok.yml'} spbgit`,47      interpreter: 'none',48      autorestart: true,49      // Exponential backoff (caps at 15 min) so the tunnel self-heals once50      // the domain reservation / network issue is fixed — without log spam.51      max_restarts: 1000,52      exp_backoff_restart_delay: 10000,53      out_file: path.join(LOG_DIR, 'tunnel-out.log'),54      error_file: path.join(LOG_DIR, 'tunnel-err.log'),55      merge_logs: true,56      time: true,57    },58  ],59};60