Traefik docker - requestAcceptGraceTimeout
Traefik docker - requestAcceptGraceTimeout
有没有人有过使用 ping 端点和设置 requestAcceptGraceTimeout
值的经验?我的 toml 中有这个:
[lifeCycle]
requestAcceptGraceTimeout = "30s"
但是,当我指示 traefik 关闭时,它仅在默认时间段(10 秒)左右提供 503:
$ time docker stop traefik
traefik
real 0m12.416s
我试过以多种不同方式设置值 30、30s、60s、1m、1h,但时间段始终在 10-12 秒左右。
有没有人成功地设置 requestAcceptGraceTimeout
并让 Traefik 接受这个值?
您看到的是 docker stop
的默认超时时间,即 10 秒。参考:https://docs.docker.com/engine/reference/commandline/stop/
测试您的 requestAcceptGraceTimeout
的一种方法是 运行 附加的 traefik
docker run -v /traefik.toml:/etc/traefik/traefik.toml -v /var/run/docker.sock:/var/run/docker.sock --name tt -i traefik --debug
,然后ctrl+c,你可以在日志中看到类似的东西,(我也有一个2s的graceTimeOut)
time="2018-11-23T10:01:38Z" level=info msg="Waiting 30s for incoming requests to cease"
time="2018-11-23T10:01:53Z" level=info msg="Stopping server gracefully"
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint traefik..."
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint https..."
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint http..."
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint https closed"
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint http closed"
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint traefik closed"
time="2018-11-23T10:01:53Z" level=info msg="Server stopped"
time="2018-11-23T10:01:53Z" level=info msg="Shutting down"
因此对于实际配置,如果您使用 docker run
启动 traefik,然后使用 docker stop -t
停止它,或者如果您在 compose
中使用 service
或 stack
,将 stop_grace_period: 30s
添加到服务中。
`
PS requestAcceptGraceTimeout
的默认值为 0s。
有没有人有过使用 ping 端点和设置 requestAcceptGraceTimeout
值的经验?我的 toml 中有这个:
[lifeCycle]
requestAcceptGraceTimeout = "30s"
但是,当我指示 traefik 关闭时,它仅在默认时间段(10 秒)左右提供 503:
$ time docker stop traefik
traefik
real 0m12.416s
我试过以多种不同方式设置值 30、30s、60s、1m、1h,但时间段始终在 10-12 秒左右。
有没有人成功地设置 requestAcceptGraceTimeout
并让 Traefik 接受这个值?
您看到的是 docker stop
的默认超时时间,即 10 秒。参考:https://docs.docker.com/engine/reference/commandline/stop/
测试您的 requestAcceptGraceTimeout
的一种方法是 运行 附加的 traefik
docker run -v /traefik.toml:/etc/traefik/traefik.toml -v /var/run/docker.sock:/var/run/docker.sock --name tt -i traefik --debug
,然后ctrl+c,你可以在日志中看到类似的东西,(我也有一个2s的graceTimeOut)
time="2018-11-23T10:01:38Z" level=info msg="Waiting 30s for incoming requests to cease"
time="2018-11-23T10:01:53Z" level=info msg="Stopping server gracefully"
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint traefik..."
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint https..."
time="2018-11-23T10:01:53Z" level=debug msg="Waiting 2s seconds before killing connections on entrypoint http..."
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint https closed"
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint http closed"
time="2018-11-23T10:01:53Z" level=debug msg="Entrypoint traefik closed"
time="2018-11-23T10:01:53Z" level=info msg="Server stopped"
time="2018-11-23T10:01:53Z" level=info msg="Shutting down"
因此对于实际配置,如果您使用 docker run
启动 traefik,然后使用 docker stop -t
停止它,或者如果您在 compose
中使用 service
或 stack
,将 stop_grace_period: 30s
添加到服务中。
`
PS requestAcceptGraceTimeout
的默认值为 0s。