module.exports = {
  apps: [
    {
      name: 'punimtag-api',
      script: 'venv/bin/uvicorn',
      args: 'backend.app:app --host 0.0.0.0 --port 8000',
      cwd: '/opt/punimtag', // CHANGE: Update to your deployment directory
      interpreter: 'none',
      env: {
        PYTHONPATH: '/opt/punimtag', // CHANGE: Update to your deployment directory
        PATH: '/opt/punimtag/venv/bin:/usr/local/bin:/usr/bin:/bin', // CHANGE: Update paths
      },
      error_file: '/home/appuser/.pm2/logs/punimtag-api-error.log', // CHANGE: Update user home directory
      out_file: '/home/appuser/.pm2/logs/punimtag-api-out.log', // CHANGE: Update user home directory
      log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
      merge_logs: true,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
    },
    {
      name: 'punimtag-worker',
      script: 'venv/bin/python',
      args: '-m backend.worker',
      cwd: '/opt/punimtag', // CHANGE: Update to your deployment directory
      interpreter: 'none',
      env: {
        PYTHONPATH: '/opt/punimtag', // CHANGE: Update to your deployment directory
        PATH: '/opt/punimtag/venv/bin:/usr/local/bin:/usr/bin:/bin', // CHANGE: Update paths
      },
      error_file: '/home/appuser/.pm2/logs/punimtag-worker-error.log', // CHANGE: Update user home directory
      out_file: '/home/appuser/.pm2/logs/punimtag-worker-out.log', // CHANGE: Update user home directory
      log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
      merge_logs: true,
      autorestart: true,
      watch: false,
      max_memory_restart: '1G',
    },
    {
      name: 'punimtag-admin',
      script: './serve.sh',
      cwd: '/opt/punimtag/admin-frontend', // CHANGE: Update to your deployment directory
      interpreter: 'bash',
      error_file: '/home/appuser/.pm2/logs/punimtag-admin-error.log', // CHANGE: Update user home directory
      out_file: '/home/appuser/.pm2/logs/punimtag-admin-out.log', // CHANGE: Update user home directory
      log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
      merge_logs: true,
      autorestart: true,
      watch: false,
    },
    {
      name: 'punimtag-viewer',
      script: 'npm',
      args: 'run start:3001',
      cwd: '/opt/punimtag/viewer-frontend', // CHANGE: Update to your deployment directory
      interpreter: 'node',
      env: {
        PORT: '3001',
      },
      error_file: '/home/appuser/.pm2/logs/punimtag-viewer-error.log', // CHANGE: Update user home directory
      out_file: '/home/appuser/.pm2/logs/punimtag-viewer-out.log', // CHANGE: Update user home directory
      log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
      merge_logs: true,
      autorestart: true,
      watch: false,
    },
  ],
};

