22

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.

Nicekiwi
  • 4,567
  • 11
  • 49
  • 88

1 Answers1

61

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
Community
  • 1
  • 1
ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • 3
    Thank you. Been banging my head for 2 days over this haha! :P Moral: Never Assume. – Nicekiwi Jun 17 '15 at 02:44
  • Holy smokes, I just experienced this weird problem too and was glad to see your answer. http://stackoverflow.com/questions/28623001/how-to-keep-laravel-queue-system-running-on-server#comment73972105_28625847 helped me too. And this looks interesting: http://stackoverflow.com/a/32851454/470749 – Ryan May 10 '17 at 02:15
  • It do not work for me after running this command then queue:work again. Old code still is applied. Please give me a help – Ngan Nguyen Jul 27 '20 at 03:18
  • 1
    @NganNguyen You probably have to restart your VM. – MrChux Jan 20 '21 at 21:40
  • restarted supervisord, and it worked. -.- – saber tabatabaee yazdi Nov 09 '21 at 10:33