【发布时间】:2016-06-30 22:57:19
【问题描述】:
我有一个使用 Laravel 5.1 编写的 Web 应用程序,它在用户请求某个页面或单击按钮时运行脚本。这应该在后台激活脚本。我已经尝试过使用作业和队列。
这是我的代码块: 我的工作.php
class myjob extends Job implements SelfHandling, ShouldQueue {
use InteractsWithQueue, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//
set_time_limit(0);
$this->writeJobLogs('Error', 'Start Execution');
//Job Processing Code
$this->writeJobLogs('Error', 'End Execution');
}
}
控制器.php
class ManageController extends Controller {
public function testJob(){
$this->dispatch(new myjob());
}
}
作业处理代码预计至少需要 10 分钟才能执行。 现在,当我运行代码时,它会引发错误,之后给出如下:
[Symfony\Component\Process\Exception\ProcessTimedOutException] 进程 ""C:\wamp\bin\php\php5.5.12\php.exe" "artisan" queue:work --queue="default" --delay=0 --memory=128 --sleep=3 - -tries=0 --env="local"" 超出 超时 60 秒。
& 作业处理代码预计将根据用户请求同时执行多次。所以我怀疑队列是否可以正常工作,或者我还有其他更好的选择。如果有,请提出建议。
【问题讨论】:
标签: php laravel symfony-process