Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 5.1 not seeing changes to Job file without VM restart

I have created a new Job in a laravel 5.1 app, running in Homestead VM. I've set it to be queued and have code in the handle method.

The handle() method previous expected a param to be passed, but is no longer required and I've removed the param form the handle method.

However, when the queue runs the job I get an error saying:

[2015-06-17 14:08:46] local.ERROR: exception 'ErrorException' with message 'Missing argument 1 for Simile\Jobs\SpecialJob::handle()' in /home/vagrant/Code/BitBucket/simile-app/app/Jobs/SpecialJob.php:31

line 31 of that file is:

public function handle()

Its not longer expecting any parameters, unless there's a default one that's not documented.

Now ANY changes I make, including comments out ALL content in the Job file are not seen when I run the queue. I will still get the same error.

Ive tried restarting nginx, php5-fpm, supervisor, beanstalkd, and running: artisan cache:clear, artisan clear-compiled, artisan optimize, composer dumpautoload.

Nothing works.

The only way I get get laravel to see any updated to the Job file is to restart the VM. vagrant halt, then vagrant up.

The job is triggered in a console command like this:

$this->dispatch(new SpecialJob($site->id));

Here is the full code of the SpecialJob.php file:

http://laravel.io/bin/qQQ3M#5

I tried created another new Job and tested, I get the same result.

All other non-job files update instantly, no issue. Its just the Job files. Like an old copy is being cached somewhere I can't find.

like image 779
Nicekiwi Avatar asked Jun 17 '15 02:06

Nicekiwi


People also ask

How do I know if a job is running in Laravel?

When a job is in laravel queue, it will be saved in jobs table, so you can check by DB. Show activity on this post. Show activity on this post. You can use the Laravel Telescope package.

Are Laravel jobs asynchronous?

Laravel Jobs are not asynchronous.

How do I rerun failed jobs in Laravel?

You can retry all failed Jobs by running: php artisan queue:retry all . The question is for Laravel 4, but yes. From Laravel 5 and forward this is the correct answer.


1 Answers

When running the queue worker as a daemon, you must tell the worker to restart after a code change.

Since daemon queue workers are long-lived processes, they will not pick up changes in your code without being restarted. So, the simplest way to deploy an application using daemon queue workers is to restart the workers during your deployment script. You may gracefully restart all of the workers by including the following command in your deployment script:

php artisan queue:restart
like image 76
ceejayoz Avatar answered Oct 15 '22 19:10

ceejayoz