aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Zhang <jeffrey.zhang@99cloud.net>2016-03-19 00:24:44 +0800
committerJeffrey Zhang <jeffrey.zhang@99cloud.net>2016-03-30 18:07:40 +0800
commitde6650874da1470f10d4561fd1e33829eaef3414 (patch)
tree6985e502e5adc5b8533dd38d625b2d15bdd32da9
parent981d8206abbe3aab42af371c8d8a76face9406b4 (diff)
downloadkolla-de6650874da1470f10d4561fd1e33829eaef3414.tar.gz
kolla-de6650874da1470f10d4561fd1e33829eaef3414.zip
Start the haproxy by using haproxy-system-wrapper
haproxy-system-wrapper is a solution for systemd from upstream. it can handle the reload graceful. Change-Id: I6a3d141af065e429bd1be1b7252f5c6df1fda3bb Closes-Bug: #1559238
-rw-r--r--ansible/roles/haproxy/templates/haproxy.json.j22
-rw-r--r--docker/haproxy/Dockerfile.j23
-rw-r--r--docker/haproxy/ensure_latest_config.sh4
-rw-r--r--docker/haproxy/extend_start.sh19
4 files changed, 5 insertions, 23 deletions
diff --git a/ansible/roles/haproxy/templates/haproxy.json.j2 b/ansible/roles/haproxy/templates/haproxy.json.j2
index d838dad83..c95dd7703 100644
--- a/ansible/roles/haproxy/templates/haproxy.json.j2
+++ b/ansible/roles/haproxy/templates/haproxy.json.j2
@@ -1,5 +1,5 @@
{
- "command": "/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid",
+ "command": "/usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid",
"config_files": [
{
"source": "{{ container_config_directory }}/haproxy.cfg",
diff --git a/docker/haproxy/Dockerfile.j2 b/docker/haproxy/Dockerfile.j2
index e4ee3664d..38f5dc5c1 100644
--- a/docker/haproxy/Dockerfile.j2
+++ b/docker/haproxy/Dockerfile.j2
@@ -14,7 +14,6 @@ RUN apt-get install -y --no-install-recommends haproxy \
{% endif %}
COPY ensure_latest_config.sh /usr/local/bin/kolla_ensure_haproxy_latest_config
-COPY extend_start.sh /usr/local/bin/kolla_extend_start
-RUN chmod 755 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_ensure_haproxy_latest_config
+RUN chmod 755 /usr/local/bin/kolla_ensure_haproxy_latest_config
{{ include_footer }}
diff --git a/docker/haproxy/ensure_latest_config.sh b/docker/haproxy/ensure_latest_config.sh
index 9a34f1758..4b84f3aed 100644
--- a/docker/haproxy/ensure_latest_config.sh
+++ b/docker/haproxy/ensure_latest_config.sh
@@ -1,12 +1,14 @@
#!/bin/bash
+set -o errexit
+
CURRENT_CONFIG_HASH=$(sha1sum /etc/haproxy/haproxy.cfg | cut -f1 -d' ')
NEW_CONFIG_HASH=$(sha1sum /var/lib/kolla/config_files/haproxy.cfg | cut -f1 -d' ')
if [[ $CURRENT_CONFIG_HASH != $NEW_CONFIG_HASH ]]; then
changed=changed
python /usr/local/bin/kolla_set_configs
- /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -sf $(cat /run/haproxy.pid)
+ kill -USR2 $(pgrep -f /usr/sbin/haproxy-systemd-wrapper)
fi
echo $changed
diff --git a/docker/haproxy/extend_start.sh b/docker/haproxy/extend_start.sh
deleted file mode 100644
index e2d13f484..000000000
--- a/docker/haproxy/extend_start.sh
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-# We are intentionally not using exec so we can reload the haproxy config later
-echo "Running command: '${CMD}'"
-$CMD
-
-retry=0
-# The loop breaks only when haproxy.pid get missing even after 3 re-try.
-while [[ $retry -lt 3 ]]; do
- if [[ ! -e /run/haproxy.pid || ! -d /proc/$(cat /run/haproxy.pid) ]]; then
- retry=$((retry+1))
- sleep 2
- continue
- fi
- retry=0
- sleep 5
-done
-
-exit 1