feat(health): info log when healthcheck passes after failure for the case of HEALTH_VPN_RESTART=off
This commit is contained in:
@@ -75,6 +75,11 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
|
|||||||
l.logger.Error(err.Error())
|
l.logger.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
l.collectHealthErrors(ctx, loopCtx, healthErrCh)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *Loop) collectHealthErrors(ctx, loopCtx context.Context, healthErrCh <-chan error) {
|
||||||
|
var previousHealthErr error
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@@ -82,6 +87,10 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
|
|||||||
return
|
return
|
||||||
case healthErr := <-healthErrCh:
|
case healthErr := <-healthErrCh:
|
||||||
l.healthServer.SetError(healthErr)
|
l.healthServer.SetError(healthErr)
|
||||||
|
if previousHealthErr != nil && healthErr == nil {
|
||||||
|
l.logger.Info("healthcheck passed successfully after previous failure(s)")
|
||||||
|
continue
|
||||||
|
}
|
||||||
if healthErr != nil {
|
if healthErr != nil {
|
||||||
if *l.healthSettings.RestartVPN {
|
if *l.healthSettings.RestartVPN {
|
||||||
// Note this restart call must be done in a separate goroutine
|
// Note this restart call must be done in a separate goroutine
|
||||||
@@ -93,6 +102,7 @@ func (l *Loop) onTunnelUp(ctx, loopCtx context.Context, data tunnelUpData) {
|
|||||||
l.logger.Warnf("healthcheck failed: %s", healthErr)
|
l.logger.Warnf("healthcheck failed: %s", healthErr)
|
||||||
l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md")
|
l.logger.Info("👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md")
|
||||||
}
|
}
|
||||||
|
previousHealthErr = healthErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user