diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-07-30 16:42:12 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-07-30 16:42:12 +0000 |
| commit | 15eb390ab307885943280a4b5d1287dc580517aa (patch) | |
| tree | b3428c473c6b2eef0c2802d07b48f26a78643010 /docker/common/haproxy | |
| parent | d4c7129dc30008f70ac07903aa27fdcd7b819321 (diff) | |
| parent | 2d920745a45eec166e2c381aa7b15b1168b03887 (diff) | |
| download | kolla-15eb390ab307885943280a4b5d1287dc580517aa.tar.gz kolla-15eb390ab307885943280a4b5d1287dc580517aa.zip | |
Merge "Ansible install of HAProxy"
Diffstat (limited to 'docker/common/haproxy')
| -rwxr-xr-x | docker/common/haproxy/config-external.sh | 3 | ||||
| -rwxr-xr-x | docker/common/haproxy/ensure_latest_config.sh | 12 | ||||
| -rwxr-xr-x | docker/common/haproxy/start.sh | 15 |
3 files changed, 22 insertions, 8 deletions
diff --git a/docker/common/haproxy/config-external.sh b/docker/common/haproxy/config-external.sh index d267eb195..0c41a5bdb 100755 --- a/docker/common/haproxy/config-external.sh +++ b/docker/common/haproxy/config-external.sh @@ -4,8 +4,7 @@ TARGET="/etc/haproxy/haproxy.cfg" OWNER="root" if [[ -f "$SOURCE" ]]; then - rm $TARGET - cp $SOURCE $TARGET + cp -f $SOURCE $TARGET chown ${OWNER}: $TARGET chmod 0644 $TARGET fi diff --git a/docker/common/haproxy/ensure_latest_config.sh b/docker/common/haproxy/ensure_latest_config.sh new file mode 100755 index 000000000..b91189ca5 --- /dev/null +++ b/docker/common/haproxy/ensure_latest_config.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +CURRENT_CONFIG_HASH=$(sha1sum /etc/haproxy/haproxy.cfg | cut -f1 -d' ') +NEW_CONFIG_HASH=$(sha1sum /opt/kolla/haproxy/haproxy.cfg | cut -f1 -d' ') + +if [[ $CURRENT_CONFIG_HASH != $NEW_CONFIG_HASH ]]; then + changed=changed + source /opt/kolla/config-external.sh + /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $(cat /run/haproxy.pid) +fi + +echo $changed diff --git a/docker/common/haproxy/start.sh b/docker/common/haproxy/start.sh index 68600f44e..c39184767 100755 --- a/docker/common/haproxy/start.sh +++ b/docker/common/haproxy/start.sh @@ -2,11 +2,7 @@ set -o errexit CMD='/usr/sbin/haproxy' -# Parameters: -# -db for non-daemon execution and logging to stdout -# -p pidfile to specify pidfile and allow hot reconfiguration -# loop which generates -f file.conf for each file in /etc/haproxy and /etc/haproxy/conf.d -ARGS="-db -f /etc/haproxy/haproxy.cfg" +ARGS="-f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid" # Loading common functions. source /opt/kolla/kolla-common.sh @@ -14,4 +10,11 @@ source /opt/kolla/kolla-common.sh # Config-internal script exec out of this function, it does not return here. set_configs -exec $CMD $ARGS +# We are intentionally not using exec so we can reload the haproxy config later +$CMD $ARGS + +# TODO(SamYaple): This has the potential for a race condition triggered by a +# config reload that could cause the container to exit +while [[ -e "/proc/$(cat /run/haproxy.pid)" ]]; do + sleep 5 +done |
