laravel 5.1 not seeing changes to Job file without VM restart

10.7k Views Asked by At

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.

1

There are 1 best solutions below

5
On BEST ANSWER

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