module.exports = {
  apps: [
    {
      name: 'embroidery-viewer-prod',
      script: './build/index.js',
      time: true,
      instances: 1,
      autorestart: true,
      max_restarts: 50,
      watch: false,
      max_memory_restart: '1G',
      env: {
        EMAIL_ACCESS_KEY: process.env.EMAIL_ACCESS_KEY,
        EMAIL_BASE_URL: process.env.EMAIL_BASE_URL,
        NODE_ENV: 'production',
        PORT: 7281,
      },
    },
  ],
  deploy: {
    production: {
      user: 'deployer',
      host: '45.76.5.44',
      key: 'deploy.key',
      ref: 'origin/main',
      repo: 'git@git.leomurca.xyz:leomurca/embroidery-viewer.git',
      path: '/home/deployer/embroidery-viewer',
      'pre-deploy':
        'rm -rf node_modules build .svelte-kit && npm ci && PUBLIC_APP_ENV=production npm run build',
      'post-deploy':
        'pm2 startOrReload ecosystem.config.cjs --only embroidery-viewer-prod --env production && pm2 save',
      env: {
        EMAIL_ACCESS_KEY: process.env.EMAIL_ACCESS_KEY,
        EMAIL_BASE_URL: process.env.EMAIL_BASE_URL,
        PORT: 7281,
        NODE_ENV: 'production',
      },
    },
  },
};
