Skip to content
Open
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
14 changes: 14 additions & 0 deletions grafana/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ fi
/run.sh "$@" &
GRAFANA_PID=$!

# This script stays PID 1 while it sets up the datasource and then waits for
# Grafana. The kernel drops SIGTERM to a PID 1 that has no handler, so without
# this trap `docker stop` never reaches Grafana and kills it after the grace
# period. Forward the signal and wait for Grafana's graceful shutdown.
stop_grafana() {
echo "Signal received; stopping Grafana (pid ${GRAFANA_PID})"
kill -TERM "$GRAFANA_PID" 2>/dev/null || true
while kill -0 "$GRAFANA_PID" 2>/dev/null; do
wait "$GRAFANA_PID" 2>/dev/null || true
done
exit 0
}
trap stop_grafana TERM INT

# Wait for Grafana API
echo "Waiting for Grafana API..."
for i in $(seq 1 60); do
Expand Down
Loading
⌂ Proxy