laravel 5.1在不重新启动虚拟机的情况下看不到作业文件的更改 [英] laravel 5.1 not seeing changes to Job file without VM restart

查看:70
本文介绍了laravel 5.1在不重新启动虚拟机的情况下看不到作业文件的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

handle()方法以前希望传递一个参数,但是不再需要,我已经从handle方法中删除了该参数.

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

该文件的

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

我尝试重新启动nginxphp5-fpmsupervisorbeanstalkd并运行:artisan cache:clearartisan clear-compiledartisan optimizecomposer dumpautoload.

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.

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));

这是SpecialJob.php文件的完整代码:

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

我尝试创建另一个新的Job并进行了测试,得到的结果相同.

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.

推荐答案

运行队列工作器时

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

这篇关于laravel 5.1在不重新启动虚拟机的情况下看不到作业文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆