这个HAProxy的“重新启动脚本”是否会像我们认为的那样优雅地工作?

我把这个脚本从各个地方放在一起。 我所希望的是,一旦运行,它将执行以下操作:

  1. 暂停端口80和443的所有“新”HTTPstream量 – 只是“暂停”他们,不要给出任何错误
  2. 当所有“进行中”请求完成时,优雅地重新启动haproxy
  3. 暂停httpstream量并像往常一样继续业务。

这是如何运行? 我错过了什么? 我们有数千个基于ip的acl规则,存储在一个haproxy引用的文件中,我们需要每分钟重新加载几次。

#!/bin/sh # hold/pause new requests iptables -I INPUT -p tcp --dport 80 --syn -j DROP iptables -I INPUT -p tcp --dport 443 --syn -j DROP sleep 1 # gracefully restart haproxy /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) # allow new requests to come in again iptables -D INPUT -p tcp --dport 80 --syn -j DROP iptables -D INPUT -p tcp --dport 443 --syn -j DROP 

编辑:我想以某种方式testing它,但我们没有任何stream量(除了我testing)。

资料来源:

http://www.forouzani.com/reload-haproxy-cfg-without-restarting.html

https://github.com/Mirantis/openstack-lbaas/issues/3

HAProxy优雅重新加载零丢包

基于这些文章,它应该工作得很好。

只要记住,你没有stream量,你总是可以模仿它。

使用Apache基准testing工具来放置一些虚假的stream量。

只要确保您正在加载的页面需要几秒钟才能加载,以testing最糟糕的情况。

我为您创build了一本食谱 ,certificate您提供的configuration是正确的。