处理 PHP-FPM 和 PHP 文件设置的执行时间
Handling execution time set by PHP-FPM and PHP file
我在 PHP-FPM 池配置文件中设置了 request_terminate_timeout
指令,目前是 100s
,我正在为个人设置 set_time_limit(600)
PHP 文件。但问题是最低触发率先触发,所以 600s
永远不会应用,我不希望如此。
是否可以全局保留 request_terminate_timeout
,同时在单个 PHP 文件中为最大执行时间设置更高的值?
我以前遇到过类似的问题。
不完全确定它是否适合您的问题,但我已尝试记录所有内容以确保提供 "safe" 提示。
对你的问题的粗暴回答我想它是否定的,因为你在 php-fpm.conf
中指定的指令大多不能从 ini_set()
改变,而 set_time_limit
几乎无非是ini_set()
上的 convenience wrapper .
set_time_limit
应该只 "overwrite" max_execution_time
指令,因为
they only affect the execution time of the script itself
(official documentation中有具体说明)。
另一方面,request_terminate_timeout
跟FPM有关,所以这里说的是流程管理层面:
should be used when the 'max_execution_time' ini option does not stop
script execution for some reason.
所以,为了尝试回答这个问题,我认为问题在于您试图将 FPM (request_terminate_timeout
) 处理的内容与 PHP 本身处理的内容 (max_execution_time
).
使用 max_execution_time 代替 request_terminate_timeout(但将其用于实际的最大上限)应该可以解决问题。
官方文档中的max_execution_time
描述对这个常见问题有提示,即:
Your web server can have other timeout configurations that may also
interrupt PHP execution. Apache has a Timeout directive and IIS has a
CGI timeout function. Both default to 300 seconds. See your web server
documentation for specific details.
注意:这个等式中的一些变量甚至可以依赖于网络服务器(例如:读取超时)。
PHP
中的 max_execution_time
应低于 njinx
中的 request_terminate_timeout
因为 PHP 会触发异常,您将能够捕获它并且当 request_terminate_timeout
会惹恼您网站的用户而不给您任何反馈时,请采取一些措施。
这就是为什么答案是“否”的原因
在我的 'php-fpm.conf' 中找不到“request_terminate_timeout”。默认值:0。值“0”表示 'Off'.
我在 PHP-FPM 池配置文件中设置了 request_terminate_timeout
指令,目前是 100s
,我正在为个人设置 set_time_limit(600)
PHP 文件。但问题是最低触发率先触发,所以 600s
永远不会应用,我不希望如此。
是否可以全局保留 request_terminate_timeout
,同时在单个 PHP 文件中为最大执行时间设置更高的值?
我以前遇到过类似的问题。 不完全确定它是否适合您的问题,但我已尝试记录所有内容以确保提供 "safe" 提示。
对你的问题的粗暴回答我想它是否定的,因为你在 php-fpm.conf
中指定的指令大多不能从 ini_set()
改变,而 set_time_limit
几乎无非是ini_set()
上的 convenience wrapper .
set_time_limit
应该只 "overwrite" max_execution_time
指令,因为
they only affect the execution time of the script itself
(official documentation中有具体说明)。
另一方面,request_terminate_timeout
跟FPM有关,所以这里说的是流程管理层面:
should be used when the 'max_execution_time' ini option does not stop script execution for some reason.
所以,为了尝试回答这个问题,我认为问题在于您试图将 FPM (request_terminate_timeout
) 处理的内容与 PHP 本身处理的内容 (max_execution_time
).
使用 max_execution_time 代替 request_terminate_timeout(但将其用于实际的最大上限)应该可以解决问题。
官方文档中的max_execution_time
描述对这个常见问题有提示,即:
Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.
注意:这个等式中的一些变量甚至可以依赖于网络服务器(例如:读取超时)。
PHP
中的 max_execution_time
应低于 njinx
中的 request_terminate_timeout
因为 PHP 会触发异常,您将能够捕获它并且当 request_terminate_timeout
会惹恼您网站的用户而不给您任何反馈时,请采取一些措施。
这就是为什么答案是“否”的原因
在我的 'php-fpm.conf' 中找不到“request_terminate_timeout”。默认值:0。值“0”表示 'Off'.