我在laravel 5.1应用程序中创建了一个新工作,运行在Homestead VM中.我已将其设置为排队,并在handle方法中包含代码.

前面的Handle()方法希望传递一个参数,但现在不再需要了,我已经从Handle方法中删除了该参数.

但是,当队列运行作业(job)时,我收到错误消息:

[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

该文件的第31行是:

public function handle()

它不再需要任何参数,除非有一个未记录的默认参数.

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.

毫无办法.

让laravel看到作业(job)文件更新的唯一方法是重启VM.vagrant halt,然后是vagrant up.

作业(job)在控制台命令中触发,如下所示:

$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.

所有其他非作业(job)文件都会立即更新,没有问题.这只是作业(job)文件.就像一份旧拷贝被缓存在我找不到的地方.

推荐答案

运行队列工作器as a daemon时,您必须告诉工作器在代码更改后重新启动.

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

Laravel相关问答推荐

在Laravel Lumen中迭代连接查询数据

Laravel将变量从模板到已发布的供应商模板

Inertiajs - 使用链接组件添加记录但无法在不使用表单的情况下清除文本区域

如何将用户对象绑定到中间件中的请求

Blade引擎:打印三重花括号

laravel 控制器中的全局变量

静态密码在默认的 Laravel 用户工厂中是如何工作的?

Laravel 5.5 在迁移文件中设置整数字段的大小

SQLSTATE [42000]:语法错误或访问冲突:1066 Not unique table/alias on relationship

Laravel 使用 Storage::put 生成唯一 ID

在 Laravel Eloquent 中,limit 与 take 有什么区别?

如何在 Laravel Eloquent 中 Select 某些字段?

Laravel 规则和正则表达式 (OR) 运算符的问题

Laravel - 更新时禁用更新时间

脚本 php artisan clear-compiled 处理 pre-update-cmd 事件返回错误(Laravel 4.1 升级)

Laravel Eloquent 多态一对一?

Laravel 如何具体构建和判断 CSRF 令牌?

Laravel 邮件密件抄送

Laravel php artisan 服务于模仿 HTTPS

如何判断是否连接到 Laravel 4 中的数据库?