diff --git a/.goreleaser.yml b/.goreleaser.yml index 2fe7e52062..c417eaa0d0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -45,6 +45,8 @@ nfpms: dst: /etc/logrotate.d/influxdb - src: scripts/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: preinstall: "scripts/pre-install.sh" postinstall: "scripts/post-install.sh" diff --git a/CHANGELOG.md b/CHANGELOG.md index 78bd1ab3db..5ce5efd278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. [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. [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] diff --git a/scripts/influxd-systemd-start.sh b/scripts/influxd-systemd-start.sh new file mode 100755 index 0000000000..7162768fa1 --- /dev/null +++ b/scripts/influxd-systemd-start.sh @@ -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 diff --git a/scripts/influxdb.service b/scripts/influxdb.service index 063d7034a5..ee48e6ced4 100644 --- a/scripts/influxdb.service +++ b/scripts/influxdb.service @@ -10,9 +10,11 @@ User=influxdb Group=influxdb LimitNOFILE=65536 EnvironmentFile=-/etc/default/influxdb2 -ExecStart=/usr/bin/influxd +ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh KillMode=control-group Restart=on-failure +Type=forking +PIDFile=/var/lib/influxdb/influxd.pid [Install] WantedBy=multi-user.target