Symfony2 命令行应用程序被“杀死”几分钟后
我有一个我构建的 Symfony2 命令行应用程序。它从 Web 服务获取大量数据进行预缓存。我遇到了一个问题,大约 5 分钟后应用程序被“杀死”。
我运行命令:
php app/console FTW:loadAuctionHouse
我的应用程序在运行时输出其步骤,几分钟后突然输出“Killed”。
所以...问题:命令行应用程序是否有内置时间限制?还是发生了一些“时髦”的事情?有人可以解释为什么会发生这种情况吗?
I have a Symfony2 command line app that I've built. It fetches a ton of data from a web service to pre-cache. I'm running into a problem where after about 5 minutes the app is "Killed".
I run the command:
php app/console FTW:loadAuctionHouse
My application outputs its steps while running, and just outputs "Killed" all of a sudden after a few minutes.
So... question: Is there a built in time limit to the command line apps? Or is there something "funky" going on? Can someone explain why this could happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
每个 php 应用程序(cli 以及 apache 或其他任何应用程序)都有执行时间限制。添加
到您的命令行工具以防止这种情况。 注意:如果陷入无限循环或某些递归循环,这将导致脚本运行到无穷大。虽然此解决方案比增加 php.ini 中的脚本执行时间更好,但仅应在真正必要时才执行此操作。
As every php application (cli as well as apache or anything else) there is a execution time limit. Add
to your command line tool to prevent this. CAUTION: This will result in a script that runs till infinity if caught in an endless loop or some recursion loop. While this solution is better than increasing the script execution time in your php.ini, it should be done only when really neccessary.
您在脚本中使用 Doctrine 吗?
在这种情况下,这可能是内存问题;每次加载实体时,EntityManager 都会保留一个引用,您需要分离/清除/刷新(取决于您的需要)您的实体。
http://www.doctrine-project.org/blog/doctrine2-batch -processing.html
http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/batch-processing.html
(链接已更新)
Are you using Doctrine in your script ?
In this case, that could be a memory issue; every time you load an Entity, the EntityManager keeps a reference, you need to detach/clear/flush (depends on your needs) your Entities.
http://www.doctrine-project.org/blog/doctrine2-batch-processing.html
http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/batch-processing.html
(Link updated)
我发现这个问题是PHP本身造成的。此后,我升级了服务器上的操作系统(进而升级了 PHP 版本),此问题已得到解决。我做了进一步的调查,发现这个问题在 php 5.3 中得到了纠正
I've discovered that this issue was caused by PHP itself. I've since upgraded the OS on my server (which in turn upgraded the PHP version) and this issue has been fixed. I did further investigation and found that this issue was corrected in php 5.3