有人使用ping端点并设置requestAcceptGraceTimeout
值有经验吗?我的toml中有这个:
[lifeCycle]
requestAcceptGraceTimeout = "30s"
但是,当我指示traefik关闭时,它仅在默认时间段(10s)左右才提供503服务:
$ time docker stop traefik
traefik
real 0m12.416s
我尝试了30、30s,60s,1m,1h的多种设置方式,但是时间段始终在10-12秒左右。
请问有没有人成功地成功设置requestAcceptGraceTimeout
并让Traefik尊重这一价值?
答案 0 :(得分:0)
您看到的是docker stop
的默认超时为10s。参考: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
停止它,或者如果您在service
或{内使用compose
{1}},将stack
添加到服务。
`
PS stop_grace_period: 30s
的默认值为0s。