- `HEALTH_OPENVPN_DURATION_INITIAL` renamed to `HEALTH_VPN_DURATION_INITIAL` with retro-compatiblity - `HEALTH_OPENVPN_DURATION_ADDITION` renamed to `HEALTH_VPN_DURATION_ADDITION` with retro-compatiblity
25 lines
619 B
Go
25 lines
619 B
Go
package healthcheck
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
"github.com/qdm12/gluetun/internal/vpn"
|
|
)
|
|
|
|
type vpnHealth struct {
|
|
looper vpn.Looper
|
|
healthyWait time.Duration
|
|
healthyTimer *time.Timer
|
|
}
|
|
|
|
func (s *Server) onUnhealthyVPN(ctx context.Context) {
|
|
s.logger.Info("program has been unhealthy for " +
|
|
s.vpn.healthyWait.String() + ": restarting VPN")
|
|
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Stopped)
|
|
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Running)
|
|
s.vpn.healthyWait += s.config.VPN.Addition
|
|
s.vpn.healthyTimer = time.NewTimer(s.vpn.healthyWait)
|
|
}
|