Skip to content

Commit

Permalink
fix(metrics): improve cleanup of old service
Browse files Browse the repository at this point in the history
The core-update action was not correctly shutdown old node-exporter instances and node-monitor services.
  • Loading branch information
gsanchietti authored Feb 28, 2025
2 parents 8cccdcf + 42c3e39 commit 3840c56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/imageroot/etc/systemd/system/node_exporter.service
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=-/etc/nethserver/core.env
WorkingDirectory=/var/lib/nethserver/node/state
Restart=always
RestartSec=3
TimeoutStartSec=120
# node_exporter exits with 143 on SIGTERM:
SuccessExitStatus=143
ExecStartPre=/bin/rm -f %t/%N.pid %t/%N.cid
ExecStartPre=/usr/bin/mkdir -p /run/node_exporter
ExecStart=/usr/bin/podman run \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ set -e
if systemctl is-enabled --quiet node_exporter ; then
systemctl restart node_exporter.service || :
else
# Make sure to stop all node_exporterX instances
systemctl stop node_exporter*.service || :
systemctl enable --now node_exporter.service
fi
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#

exec 1>&2
set -e

if systemctl -q is-active node-monitor.service; then
echo "Disabling node-monitor as service"
systemctl stop node-monitor
# The disable may fail if the update-core has already removed the service file
systemctl disable --now node-monitor
rm -f /etc/systemd/system/node-monitor.service
rm -fv /etc/systemd/system/node-monitor.service
systemctl daemon-reload
fi

0 comments on commit 3840c56

Please sign in to comment.