.env
中的配置項 QUEUE_DRIVER
爲 database
php artisan queue:table
php artisan migrate
php artisan make:job SendReminderEmail
$this->dispatch(new SendRemindEmail())
生產隊列,因而 database jobs
中記錄了最新添加的隊列任務php artisan queue:work
php artisan queue:listen
sudo apt-get install beanstalkd
service beanstalkd start
/usr/bin/beanstalkd -l 127.0.0.1 -p 11300
composer require pda/pheanstalk
.env
中的配置項 QUEUE_DRIVER
爲 beanstalkd
composer
可執行 composer create-project ptrofimov/beanstalk_console -s dev
,若是使用laradock
可直接 docker-composer up -d beanstalk-console
sudo apt-get install supervisor
, 也能夠去官網下載最新穩定版本cd /etc/supervisor/conf.d/demo.conf
,配置項模板以下sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start demo:*
[program:demo] process_name=%(program_name)s_%(process_num)02d command=php /your-project-path/artisan queue:listen --tries=3 autostart=true autorestart=true numprocs=8 redirect_stderr=true stdout_logfile=/your-project-path/storage/logs/worker.log
Script Maker Day Day Up!php