feat(healthcheck): log out last error when auto healing VPN

This commit is contained in:
Quentin McGaw
2024-11-05 13:32:47 +00:00
parent ddfcbe1bee
commit 6ac7ca4f0f
2 changed files with 3 additions and 3 deletions

View File

@@ -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

View File

@@ -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)