调试卡住(非终止)的 PHP 进程?

发布于 12-22 11:05 字数 314 浏览 2 评论 0原文

作为通过 gdb 等进行 Linux 调试的相对新手,我正在寻求帮助来解决我们遇到的问题。

在托管/托管的“VPS”(虚拟专用服务器 - 我们大部分但不完全控制配置)上,我们观察到偶尔的 PHP 进程“永远”存在。大多数网络点击都会正常出现和消失,但如果我们不亲自识别并杀死它们,这些点击将持续数十分钟。

我想将 gdb 附加到进程并获取堆栈跟踪,但我不知道如何实现。我也不确定我们是否需要在启用调试的情况下运行 PHP。

有没有更简单的方法(也许在 PHP 代码本身中)来识别长时间运行的 PHP 进程?如果事情很简单,比如陷入无限轮询循环,可能会对我们有所帮助。

As a relative newbie in the world of Linux debugging via gdb, etc. I'm looking for help with an issue we're seeing.

On a hosted/managed "VPS" (virtual private server - we're mostly, but not entirely, in control of the configuration) we observe that occasional PHP processes stick around "forever". Most web hits come and go normally, but these ones will last for tens of minutes if we don't identify and kill them ourselves.

I'd like to gdb attach to the processes and get a stack trace, but I'm not sure how. I'm also not sure if we need to be running PHP with debugging enabled.

Is there an easier way (maybe in the PHP code itself) to identify long-running PHP processes? Might help us if it's something simple like getting stuck in an infinite polling loop.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾挽2024-12-29 11:05:57

PHP 具有自动终止功能,可防止脚本执行超过一定时间限制,请查看 max_execution_time .ini 设置,以及 set_time_limit() 函数。

您仍然应该找出导致脚本不死的原因,但这可以省去您手动杀死它们的麻烦。

PHP has an auto-kill feature that prevents scripts from executing past a certain time limit, look into the max_execution_time .ini setting, and the set_time_limit() function.

You should still figure out what's causing the script to not die, but this'll save you trouble of having to kill them manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文