shutdown_error_log

检查 Nginx 关闭阶段的错误日志内容。

语法

--- shutdown_error_log 段专门检查 Nginx 在关闭(shutdown)阶段写入的日志。这些日志发生在请求处理完成之后、进程退出之前。常用于检查 worker 退出时的 timer、cleanup handler 等行为。

perl
1=== TEST 1: check shutdown log
2--- config
3 location /t {
4 content_by_lua_block {
5 local function cleanup()
6 ngx.log(ngx.NOTICE, "cleanup done")
7 end
8 ngx.timer.at(0, cleanup)
9 ngx.say("ok")
10 }
11 }
12--- request
13GET /t
14--- shutdown_error_log
15cleanup done

shutdown_error_log 对于验证 timer 回调、shared dict 清理等异步操作在进程退出时的行为非常重要。