From 5d1673cd7abbf3f543f65f4c36b15a7cc6c916b8 Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Fri, 16 Jul 2021 09:27:34 -0700 Subject: [PATCH 1/2] fix: systemd unit should block on startup until http endpoint is ready --- .../fs/usr/local/bin/influxdb_packages.bash | 2 ++ scripts/influxd-systemd-start.sh | 17 +++++++++++++++++ scripts/influxdb.service | 2 ++ 3 files changed, 21 insertions(+) create mode 100755 scripts/influxd-systemd-start.sh diff --git a/releng/packages/fs/usr/local/bin/influxdb_packages.bash b/releng/packages/fs/usr/local/bin/influxdb_packages.bash index 79cc2221f87..d2adb5ea718 100755 --- a/releng/packages/fs/usr/local/bin/influxdb_packages.bash +++ b/releng/packages/fs/usr/local/bin/influxdb_packages.bash @@ -87,6 +87,8 @@ elif [ "$OS" == "linux" ] || [ "$OS" == "darwin" ]; then chmod 0644 "$PKG_ROOT/usr/lib/influxdb/scripts/init.sh" cp /isrc/scripts/influxdb.service "$PKG_ROOT/usr/lib/influxdb/scripts/influxdb.service" chmod 0644 "$PKG_ROOT/usr/lib/influxdb/scripts/influxdb.service" + cp /isrc/scripts/influxd-systemd-start.sh "$PKG_ROOT/usr/lib/influxdb/scripts/influxd-systemd-start.sh" + chmod 0744 "$PKG_ROOT/usr/lib/influxdb/scripts/influxd-systemd-start.sh" # Copy logrotate script. cp /isrc/scripts/logrotate "$PKG_ROOT/etc/logrotate.d/influxdb" diff --git a/scripts/influxd-systemd-start.sh b/scripts/influxd-systemd-start.sh new file mode 100755 index 00000000000..78d6118c315 --- /dev/null +++ b/scripts/influxd-systemd-start.sh @@ -0,0 +1,17 @@ +#!/bin/bash -e + +/usr/bin/influxd -config /etc/influxdb/influxdb.conf $INFLUXD_OPTS & +echo $! > /var/lib/influxdb/influxd.pid + +BIND_ADDRESS=$(influxd print-config --key-name http-bind-address) +HOST=${BIND_ADDRESS%%:*} +HOST=${HOST:-"localhost"} +PORT=${BIND_ADDRESS##*:} + +set +e +result=$(curl -s -o /dev/null http://$HOST:$PORT/ready -w %{http_code}) +while [ "$result" != "200" ]; do + sleep 1 + result=$(curl -s -o /dev/null http://$HOST:$PORT/ready -w %{http_code}) +done +set -e diff --git a/scripts/influxdb.service b/scripts/influxdb.service index 25c2ffe9a43..5e48759984d 100644 --- a/scripts/influxdb.service +++ b/scripts/influxdb.service @@ -13,6 +13,8 @@ EnvironmentFile=-/etc/default/influxdb ExecStart=/usr/bin/influxd -config /etc/influxdb/influxdb.conf $INFLUXD_OPTS KillMode=control-group Restart=on-failure +Type=forking +PIDFile=/var/lib/influxdb/influxd.pid [Install] WantedBy=multi-user.target From 12df7f90775aebf25f13d9ca8e770e9ca67c2d02 Mon Sep 17 00:00:00 2001 From: Cody Shepherd Date: Fri, 16 Jul 2021 09:30:52 -0700 Subject: [PATCH 2/2] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 471b21859a4..ace271e405c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ v1.8.7 [unreleased] - [#21749](https://github.com/influxdata/influxdb/pull/21749): fix: rename arm rpms with yum-compatible names - [#21775](https://github.com/influxdata/influxdb/pull/21775): fix: convert arm arch names for rpms during builds via docker +- [#21865](https://github.com/influxdata/influxdb/pull/21865): fix: systemd unit should block on startup until http endpoint is ready v1.8.6 [2021-05-20] -------------------