Restructure shutdown logic used during updates. (#19781)
- 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.
Austin S. Hemmelgarn committed
Mar 5, 2025 at 12:04 UTC
717df9f39fe233d32616c4e4bebfe0e8470131ff
1 file changed
+15
-7
packaging/installer/functions.sh
+15
-7
@@ -819,35 +819,43 @@ stop_all_netdata() {
819
if [ -n "${NETDATA_STOP_CMD}" ]; then
820
if ${NETDATA_STOP_CMD}; then
821
stop_success=1
822
- sleep 5
822
fi
823
elif issystemd; then
824
if systemctl stop netdata; then
825
stop_success=1
827
- sleep 5
826
fi
827
elif [ "${uname}" = "Darwin" ]; then
828
if launchctl stop netdata; then
829
stop_success=1
832
- sleep 5
830
fi
831
elif [ "${uname}" = "FreeBSD" ]; then
832
if /etc/rc.d/netdata stop; then
833
stop_success=1
837
- sleep 5
834
fi
835
else
836
if service netdata stop; then
837
stop_success=1
842
- sleep 5
838
fi
839
fi
840
fi
841
842
+ if [ "${stop_success}" = "1" ]; then
843
+ sleep 30
844
+
845
+ if [ -n "$(netdata_pids)" ]; then
846
+ stop_success=0
847
+ fi
848
+ fi
849
+
850
if [ "$stop_success" = "0" ]; then
851
if [ -n "$(netdata_pids)" ] && [ -n "$(command -v netdatacli)" ]; then
849
- netdatacli shutdown-agent
850
- sleep 20
852
+ for p in /tmp/netdata-ipc /run/netdata/netdata.pipe /var/run/netdata/netdata.pipe /tmp/netdata/netdata.pipe; do
853
+ if [ -f "${p}" ]; then
854
+ NETDATA_PIPENAME="${p}" netdatacli shutdown-agent && break
855
+ fi
856
+ done
857
+
858
+ sleep 30
859
fi
860
861
for p in $(netdata_pids); do