Skip to content

Instantly share code, notes, and snippets.

@eliyas5044
Created October 5, 2023 10:28
Show Gist options
  • Save eliyas5044/f87d8ad75b2cb9abd397f983b27dae07 to your computer and use it in GitHub Desktop.
Save eliyas5044/f87d8ad75b2cb9abd397f983b27dae07 to your computer and use it in GitHub Desktop.
Laravel queue server using PM2

PM2

We can keep running of Laravel queue server using pm2.

  • Create a pm2 config file
nano ecosystem.config.js
  • Update the config file
module.exports = {
  apps: [
    {
      name: 'laravel-queue',
      script: 'artisan',
      args: 'queue:work --sleep=3 --tries=3 --max-time=3600',
      instances : 1,
      exec_mode : 'fork',
      interpreter: '/usr/bin/php',
      autorestart: true,
      watch: false,
      max_memory_restart: '100M',
      error_file: './storage/logs/queue.error.log',
      out_file: './storage/logs/queue.out.log',
      pid_file: './storage/logs/queue.pid.log',
      cwd: "/var/www/api",
    },
  ],
};
  • Start the process
pm2 start laravel-queue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment