Files
gluetun/internal/healthcheck/openvpn.go

25 lines
667 B
Go
Raw Normal View History

package healthcheck
import (
"context"
"time"
"github.com/qdm12/gluetun/internal/constants"
"github.com/qdm12/gluetun/internal/openvpn"
)
type openvpnHealth struct {
looper openvpn.Looper
healthyWait time.Duration
healthyTimer *time.Timer
}
func (s *Server) onUnhealthyOpenvpn(ctx context.Context) {
s.logger.Info("program has been unhealthy for " +
2021-07-22 20:18:52 +00:00
s.openvpn.healthyWait.String() + ": restarting OpenVPN")
_, _ = s.openvpn.looper.ApplyStatus(ctx, constants.Stopped)
_, _ = s.openvpn.looper.ApplyStatus(ctx, constants.Running)
2021-07-22 20:18:52 +00:00
s.openvpn.healthyWait += s.config.OpenVPN.Addition
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.healthyWait)
}