fix: systemd unit should block on startup until http endpoint is ready (#21850)

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

* chore: update changelog
pull/21879/head
Cody Shepherd 2021-07-16 08:13:26 -07:00 committed by GitHub
parent c62d4cdc24
commit c8de72ddbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View File

@ -45,6 +45,8 @@ nfpms:
dst: /etc/logrotate.d/influxdb dst: /etc/logrotate.d/influxdb
- src: scripts/influxdb2-upgrade.sh - src: scripts/influxdb2-upgrade.sh
dst: /usr/share/influxdb/influxdb2-upgrade.sh dst: /usr/share/influxdb/influxdb2-upgrade.sh
- src: scripts/influxd-systemd-start.sh
dst: /usr/lib/influxdb/scripts/influxd-systemd-start.sh
scripts: scripts:
preinstall: "scripts/pre-install.sh" preinstall: "scripts/pre-install.sh"
postinstall: "scripts/post-install.sh" postinstall: "scripts/post-install.sh"

View File

@ -45,6 +45,7 @@ This release adds an embedded SQLite database for storing metadata required by t
1. [21844](https://github.com/influxdata/influxdb/pull/21844): Upgrade to latest version of `influxdata/cron` so that tasks can be created with interval of `every: 1w`. 1. [21844](https://github.com/influxdata/influxdb/pull/21844): Upgrade to latest version of `influxdata/cron` so that tasks can be created with interval of `every: 1w`.
1. [21849](https://github.com/influxdata/influxdb/pull/21849): Specify which fields are missing when rejecting an incomplete onboarding request. 1. [21849](https://github.com/influxdata/influxdb/pull/21849): Specify which fields are missing when rejecting an incomplete onboarding request.
1. [21839](https://github.com/influxdata/influxdb/pull/21839): Fix display and parsing of `influxd upgrade` CLI prompts in PowerShell. 1. [21839](https://github.com/influxdata/influxdb/pull/21839): Fix display and parsing of `influxd upgrade` CLI prompts in PowerShell.
1. [21850](https://github.com/influxdata/influxdb/pull/21850): Systemd unit should block on startup until http endpoint is ready
## v2.0.7 [2021-06-04] ## v2.0.7 [2021-06-04]

View File

@ -0,0 +1,17 @@
#!/bin/bash -e
/usr/bin/influxd &
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

View File

@ -10,9 +10,11 @@ User=influxdb
Group=influxdb Group=influxdb
LimitNOFILE=65536 LimitNOFILE=65536
EnvironmentFile=-/etc/default/influxdb2 EnvironmentFile=-/etc/default/influxdb2
ExecStart=/usr/bin/influxd ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh
KillMode=control-group KillMode=control-group
Restart=on-failure Restart=on-failure
Type=forking
PIDFile=/var/lib/influxdb/influxd.pid
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target