How to keep Laravel Queue system running on server

后端 未结 17 1044
小鲜肉
小鲜肉 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:15

    For CentOS7

    yum install supervisor
    

    Then create a file in /etc/supervisord.d/filename.ini With content

    [program:laravel-worker]
    command=/usr/bin/php /home/appuser/public_html/artisan queue:listen
    process_name=%(program_name)s_%(process_num)02d
    numprocs=5
    priority=999
    autostart=true
    autorestart=true
    startsecs=1
    startretries=3
    user=appuser
    redirect_stderr=true
    stdout_logfile=/path/logpath/artisan.log
    

    Then start the supervisord service using

    systemctl restart supervisord
    

    Enable supervisord service to run on boot using

    systemctl enable supervisord
    

    Check if the service is running using

    ps aux | grep artisan
    

    You should see the process running if it was set up properly. Similar to the output below.

    [root@server ~]# ps aux | grep artisan
    appuser 17444  0.1  0.8 378656 31068 ?        S    12:43   0:05 /usr/bin/php /home/appuser/public_html/artisan queue:listen
    

提交回复
热议问题