vel*_*lo9 5 php nginx request abort
我知道Nginx与PHP-FPM进程无关,但是我更希望如果用户中止而导致PHP-FPM进程死亡,那么它就不会继续做不必要的事情或浪费资源。对于PHP-FPM / Nginx,trigger_error无论用户中止如何都会发生:
<?php
sleep(30);
trigger_error('Still happened?');
?>
Run Code Online (Sandbox Code Playgroud)
用户如何中止PHP-FPM?(如果可能的话)
您可以决定是否希望客户端断开连接导致脚本中止。
根据 PHP 手册:连接处理
要设置此行为,请使用ignore_user_abort
ignore_user_abort(FALSE);客户端断开连接后将中止 PHP 脚本的运行。
ignore_user_abort(TRUE);将忽略客户端断开连接并继续运行脚本。
在第二种情况下,您可能还想使用set_time_limit based on your needs to give your script enough time to accomplish the task.
此设置已在PHP-FPM/nginx环境中成功测试。
| 归档时间: |
|
| 查看次数: |
4801 次 |
| 最近记录: |