How to keep Laravel Queue system running on server

后端 未结 17 1042
小鲜肉
小鲜肉 2020-11-28 02:23

I recently setup a Laravel Queue system. The basics are a cronjob calls a command which adds jobs to a queue and calls a second command which sends an email.

The sy

17条回答
  •  盖世英雄少女心
    2020-11-28 03:11

    You should use linux supervisor

    Installation is simple and on Ubuntu I can install it with following command:

    apt-get install supervisor
    

    Supervisor configuration files are located in /etc/supervisor/conf.d directory.

    [program:email-queue]
    process_name=%(program_name)s_%(process_num)02d
    command=php /var/www/laravel-example/artisan queue:work redis --queue=emailqueue --sleep=3 --tries=3
    autostart=true
    autorestart=true
    user=forge
    numprocs=2
    redirect_stderr=true
    stdout_logfile=/var/www/laravel-example//storage/logs/supervisord.log
    

    For each process you should create a new process configuration file. With this configuration, listener will retry each job 3 times. Also Supervisor will restart listener if it fails or if system restarts.

提交回复
热议问题