0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-09 15:47:53 +00:00

Restructure shutdown logic used during updates. ()

- Don’t blindly trust that the service manager actually shut down the
  agent.
- Bump timeouts between each method of shutting down the agent to 30
  seconds to make it more likely that the agent actually shuts down
  before we try to shut it down a different way.
- Add logic to handle different possible locations for netdatacli pipe.
This commit is contained in:
Austin S. Hemmelgarn 2025-03-05 12:04:17 -05:00 committed by GitHub
parent f25e15696f
commit 717df9f39f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -819,35 +819,43 @@ stop_all_netdata() {
if [ -n "${NETDATA_STOP_CMD}" ]; then if [ -n "${NETDATA_STOP_CMD}" ]; then
if ${NETDATA_STOP_CMD}; then if ${NETDATA_STOP_CMD}; then
stop_success=1 stop_success=1
sleep 5
fi fi
elif issystemd; then elif issystemd; then
if systemctl stop netdata; then if systemctl stop netdata; then
stop_success=1 stop_success=1
sleep 5
fi fi
elif [ "${uname}" = "Darwin" ]; then elif [ "${uname}" = "Darwin" ]; then
if launchctl stop netdata; then if launchctl stop netdata; then
stop_success=1 stop_success=1
sleep 5
fi fi
elif [ "${uname}" = "FreeBSD" ]; then elif [ "${uname}" = "FreeBSD" ]; then
if /etc/rc.d/netdata stop; then if /etc/rc.d/netdata stop; then
stop_success=1 stop_success=1
sleep 5
fi fi
else else
if service netdata stop; then if service netdata stop; then
stop_success=1 stop_success=1
sleep 5
fi fi
fi fi
fi fi
if [ "${stop_success}" = "1" ]; then
sleep 30
if [ -n "$(netdata_pids)" ]; then
stop_success=0
fi
fi
if [ "$stop_success" = "0" ]; then if [ "$stop_success" = "0" ]; then
if [ -n "$(netdata_pids)" ] && [ -n "$(command -v netdatacli)" ]; then if [ -n "$(netdata_pids)" ] && [ -n "$(command -v netdatacli)" ]; then
netdatacli shutdown-agent for p in /tmp/netdata-ipc /run/netdata/netdata.pipe /var/run/netdata/netdata.pipe /tmp/netdata/netdata.pipe; do
sleep 20 if [ -f "${p}" ]; then
NETDATA_PIPENAME="${p}" netdatacli shutdown-agent && break
fi
done
sleep 30
fi fi
for p in $(netdata_pids); do for p in $(netdata_pids); do