module.exports = {
  apps: [
    {
      name: 'fitcrm-api',
      cwd: '/home/fitcrm/apps/api',
      script: 'dist/main.js',
      interpreter: 'node',
      node_args: '--enable-source-maps',
      env: {
        NODE_ENV: 'development',
        API_PORT: 3000,
        DATABASE_URL: 'postgresql://fitcrm:fitcrm_dev_password@localhost:5432/fitcrm?schema=public',
        REDIS_HOST: 'localhost',
        REDIS_PORT: 6379,
        REDIS_PASSWORD: 'redis_dev_password',
        JWT_SECRET: 'jwt_dev_secret_change_in_production',
        JWT_REFRESH_SECRET: 'jwt_refresh_dev_secret_change_in_production',
      },
      watch: false,
      max_memory_restart: '1G',
      error_file: '/home/fitcrm/logs/api-error.log',
      out_file: '/home/fitcrm/logs/api-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-web-admin',
      cwd: '/home/fitcrm/apps/web-admin',
      script: 'node_modules/next/dist/bin/next',
      args: 'dev --port 3001 --hostname 0.0.0.0',
      interpreter: 'node',
      env: {
        NODE_ENV: 'development',
      },
      watch: false,
      max_memory_restart: '512M',
      error_file: '/home/fitcrm/logs/web-admin-error.log',
      out_file: '/home/fitcrm/logs/web-admin-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-web-club-admin',
      cwd: '/home/fitcrm/apps/web-club-admin',
      script: 'node_modules/next/dist/bin/next',
      args: 'dev --port 3002 --hostname 0.0.0.0',
      interpreter: 'node',
      env: {
        NODE_ENV: 'development',
      },
      watch: false,
      max_memory_restart: '512M',
      error_file: '/home/fitcrm/logs/club-admin-error.log',
      out_file: '/home/fitcrm/logs/club-admin-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-web-platform-admin',
      cwd: '/home/fitcrm/apps/web-platform-admin',
      script: 'node_modules/next/dist/bin/next',
      args: 'dev --port 3003 --hostname 0.0.0.0',
      interpreter: 'node',
      env: {
        NODE_ENV: 'development',
      },
      watch: false,
      max_memory_restart: '512M',
      error_file: '/home/fitcrm/logs/platform-admin-error.log',
      out_file: '/home/fitcrm/logs/platform-admin-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-lp',
      cwd: '/home/fitcrm/apps/lp',
      script: 'node_modules/next/dist/bin/next',
      args: 'start --port 3050 --hostname 0.0.0.0',
      interpreter: 'node',
      env: {
        NODE_ENV: 'production',
      },
      watch: false,
      max_memory_restart: '256M',
      error_file: '/home/fitcrm/logs/lp-error.log',
      out_file: '/home/fitcrm/logs/lp-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-mobile-expo',
      cwd: '/home/fitcrm/apps/mobile',
      script: 'node_modules/expo/bin/cli',
      args: 'start --port 8081 --lan',
      interpreter: 'node',
      env: {
        REACT_NATIVE_PACKAGER_HOSTNAME: '80.87.104.29',
        EXPO_NO_TELEMETRY: '1',
      },
      watch: false,
      max_memory_restart: '512M',
      error_file: '/home/fitcrm/logs/mobile-expo-error.log',
      out_file: '/home/fitcrm/logs/mobile-expo-out.log',
      merge_logs: true,
      time: true,
    },
    {
      name: 'fitcrm-watchdog',
      cwd: '/home/fitcrm/apps/watchdog',
      script: 'dist/index.js',
      interpreter: 'node',
      env: {
        NODE_ENV: 'production',
        TELEGRAM_BOT_TOKEN:
          process.env.TELEGRAM_BOT_TOKEN || '8358282802:AAHwKyAo6y-edt2pN7QskKgy1_-sz1zPw34',
        TELEGRAM_CHAT_ID: process.env.TELEGRAM_CHAT_ID || '-5177229949',
        REDIS_PASSWORD: process.env.REDIS_PASSWORD || 'redis_dev_password',
      },
      watch: false,
      max_memory_restart: '128M',
      error_file: '/home/fitcrm/logs/watchdog/watchdog-error.log',
      out_file: '/home/fitcrm/logs/watchdog/watchdog-out.log',
      merge_logs: true,
      time: true,
    },
  ],
};
