/** * PM2 进程管理配置 * * 用法: * pm2 start ecosystem.config.js # 启动全部 * pm2 start ecosystem.config.js --only laralog-workerman * pm2 logs laralog-workerman * pm2 save && pm2 startup # 开机自启 * * 说明: * - workerman 负责队列消费(database/redis)+ WebSocket 推送 * - schedule 常驻运行 Laravel 调度器(替代 cron) * - 若不想用 Workerman,可改用注释掉的 laralog-queue(标准 queue:work) */ module.exports = { apps: [ { name: 'laralog-workerman', script: 'artisan', args: 'workerman:serve start', interpreter: 'php', cwd: '/var/www/laralog', instances: 1, autorestart: true, watch: false, max_memory_restart: '512M', time: true, env: { APP_ENV: 'production', APP_DEBUG: 'false', // 队列连接:database 或 redis WORKERMAN_QUEUE_CONNECTION: 'redis', WORKERMAN_QUEUES: 'default,ai', }, }, { name: 'laralog-schedule', script: 'artisan', args: 'schedule:work', interpreter: 'php', cwd: '/var/www/laralog', instances: 1, autorestart: true, max_memory_restart: '256M', time: true, env: { APP_ENV: 'production', }, }, // 不使用 Workerman 时的标准队列消费者(二选一) // { // name: 'laralog-queue', // script: 'artisan', // args: 'queue:work redis --sleep=3 --tries=3 --max-time=3600', // interpreter: 'php', // cwd: '/var/www/laralog', // instances: 2, // autorestart: true, // max_memory_restart: '512M', // time: true, // env: { APP_ENV: 'production' }, // }, ], }