From 6ac7ca4f0fb66a96a62d9c5e2df85eb9fb85e0d7 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Tue, 5 Nov 2024 13:32:47 +0000 Subject: [PATCH] feat(healthcheck): log out last error when auto healing VPN --- internal/healthcheck/health.go | 2 +- internal/healthcheck/openvpn.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/healthcheck/health.go b/internal/healthcheck/health.go index c290948e..c93b18b2 100644 --- a/internal/healthcheck/health.go +++ b/internal/healthcheck/health.go @@ -53,7 +53,7 @@ func (s *Server) runHealthcheckLoop(ctx context.Context, done chan<- struct{}) { select { case <-s.vpn.healthyTimer.C: timeoutIndex = 0 // retry next with the smallest timeout - s.onUnhealthyVPN(ctx) + s.onUnhealthyVPN(ctx, err.Error()) default: } case previousErr == nil && err == nil: // Nth success diff --git a/internal/healthcheck/openvpn.go b/internal/healthcheck/openvpn.go index fa6c8c3e..34583b48 100644 --- a/internal/healthcheck/openvpn.go +++ b/internal/healthcheck/openvpn.go @@ -13,9 +13,9 @@ type vpnHealth struct { healthyTimer *time.Timer } -func (s *Server) onUnhealthyVPN(ctx context.Context) { +func (s *Server) onUnhealthyVPN(ctx context.Context, lastErrMessage string) { s.logger.Info("program has been unhealthy for " + - s.vpn.healthyWait.String() + ": restarting VPN") + s.vpn.healthyWait.String() + ": restarting VPN (healthcheck error: " + lastErrMessage + ")") s.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md") s.logger.Info("DO NOT OPEN AN ISSUE UNLESS YOU READ AND TRIED EACH POSSIBLE SOLUTION") _, _ = s.vpn.loop.ApplyStatus(ctx, constants.Stopped)