Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: systemd unit should block on startup until http endpoint is ready #21865

Merged
merged 2 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
-------------------
Expand Down
2 changes: 2 additions & 0 deletions releng/packages/fs/usr/local/bin/influxdb_packages.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions scripts/influxd-systemd-start.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions scripts/influxdb.service
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down