简体   繁体   中英

Laravel unable to modify queued job code

When I send a job that fails due to an exception such as 'ErrorException' with message 'Undefined variable: sender' and I fix the code and re-fire the event, the previous code runs again and I get the same error.

I have no idea why Laravel re-runs my old code over and over. I'd obviously like to be able to fix the mistakes that are breaking my job execution.

I've tried both composer dump-autoload and php artisan queue:flush and those have no effect. Any help?

My Laravel 5.1 config/compile.php file is empty but this helped me:

sudo service beanstalkd restart

and

php artisan queue:restart

Laravel often lacks of good and accurate documentation.

You need to run php artisan clear-compiled to clear compiled files.

If you look at config/compile.php you will see some extra providers (or other classes) are cached by default by Laravel.

If you made any changes for example in EventServiceProvider and it was earlier cached, Laravel won't see those changes in case php artisan optimize command was earlier launched (and looking at https://github.com/laravel/laravel/blob/master/composer.json you will see it is launched after running composer install or composer update ).

This feature has nothing in common with composer itself but with Laravel that's why running composer dump-autoload won't help.

In my case, supervisor was the issue.

This is the only process that works consistently for me:

  1. run 'service supervisor stop'
  2. run 'service supervisor start'
  3. quit your browser, restart it, clear the cache and try again

Note: running 'service supervisor restart' had no effect.

I'm using Lumen and ran into the same issue. I tried php artisan queue:restart , which did nothing. I then found this thread and tried php artisan clear-compiled , as per the winning answer, but got the error:

Command "clear-compiled" is not defined.

I then saw that Artisan had the option php artisan cache:clear , which did the trick! When I fire that command followed by php artisan queue:work , my new job code is used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM