Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions utils/nvfd-fan-control.service
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[Unit]
Description=NVIDIA Fan Control - Temperature-aware per-GPU mode switching
After=nvfd.service
Wants=nvfd.service
StartLimitIntervalSec=400
StartLimitBurst=3

[Service]
Type=simple
ExecStart=/usr/local/bin/nvfd-fan-control.sh --threshold-up 45 --threshold-down 35
Restart=always
RestartSec=5
Restart=on-failure
RestartSec=90
User=root

[Install]
Expand Down
10 changes: 10 additions & 0 deletions utils/nvfd-fan-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ done
# Check for root privileges
[[ "$EUID" -ne 0 ]] && { echo "ERROR: This script must be run as root (use sudo)" >&2; exit 1; }

# Wait for nvfd service to be active (up to 30 seconds)
# Systemd handles restart rate limiting via StartLimitBurst/StartLimitIntervalSec
echo "[INFO] Waiting for nvfd service to be ready..."
for i in {1..30}; do
systemctl is-active --quiet nvfd.service && break
[[ $i -eq 30 ]] && { echo "[ERROR] nvfd service not ready after 30 seconds. Exiting." >&2; exit 1; }
sleep 1
done
echo "[INFO] nvfd service is ready"

# Acquire file lock to prevent multiple instances
exec 200>"$LOCKFILE"
if ! flock -n 200; then
Expand Down
Loading