Skip to content

Instantly share code, notes, and snippets.

@ratul0
Created May 30, 2017 04:29
Show Gist options
  • Save ratul0/1d76b689cfbfe9d948580adbac0ec672 to your computer and use it in GitHub Desktop.
Save ratul0/1d76b689cfbfe9d948580adbac0ec672 to your computer and use it in GitHub Desktop.
Laravel mail with supervisor

Frist run this migrations :

php artisan queue:table

php artisan queue:failed-table

php artisan migrate

create a job using artisan

php artisan make:job TestJob --queued

Then dispatch the job when appropriate

$job = (new TestJob($user))->delay(10);
$this->dispatch($job);

Create a "laravel-worker.conf" in /etc/supervisor/conf.d folder

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/app/artisan queue:work database --sleep=3 --tries=3 --daemon
autostart=true
autorestart=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/app/worker.log

After saving the file run these commands

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start laravel-worker:*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment