Maint: improve health code
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
func (s *server) runHealthcheckLoop(ctx context.Context, done chan<- struct{}) {
|
||||
defer close(done)
|
||||
|
||||
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.currentHealthyWait)
|
||||
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.healthyWait)
|
||||
|
||||
for {
|
||||
previousErr := s.handler.getErr()
|
||||
@@ -23,10 +23,11 @@ func (s *server) runHealthcheckLoop(ctx context.Context, done chan<- struct{}) {
|
||||
if previousErr != nil && err == nil {
|
||||
s.logger.Info("healthy!")
|
||||
s.openvpn.healthyTimer.Stop()
|
||||
s.openvpn.currentHealthyWait = s.openvpn.healthyWaitConfig.Initial
|
||||
s.openvpn.healthyWait = s.config.OpenVPN.Initial
|
||||
} else if previousErr == nil && err != nil {
|
||||
s.logger.Info("unhealthy: " + err.Error())
|
||||
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.currentHealthyWait)
|
||||
s.openvpn.healthyTimer.Stop()
|
||||
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.healthyWait)
|
||||
}
|
||||
|
||||
if err != nil { // try again after 1 second
|
||||
|
||||
Reference in New Issue
Block a user