2021-07-18 03:17:48 +00:00
|
|
|
package healthcheck
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/qdm12/gluetun/internal/constants"
|
|
|
|
|
)
|
|
|
|
|
|
2021-08-18 22:01:04 +00:00
|
|
|
type vpnHealth struct {
|
2022-06-11 01:34:30 +00:00
|
|
|
loop StatusApplier
|
2021-07-23 19:22:41 +00:00
|
|
|
healthyWait time.Duration
|
|
|
|
|
healthyTimer *time.Timer
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-11 21:04:21 +00:00
|
|
|
func (s *Server) onUnhealthyVPN(ctx context.Context) {
|
2021-07-18 03:17:48 +00:00
|
|
|
s.logger.Info("program has been unhealthy for " +
|
2023-03-25 15:09:13 +00:00
|
|
|
s.vpn.healthyWait.String() + ": restarting VPN " +
|
2023-06-30 10:31:26 +00:00
|
|
|
"(see https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md)")
|
2022-06-11 01:34:30 +00:00
|
|
|
_, _ = s.vpn.loop.ApplyStatus(ctx, constants.Stopped)
|
|
|
|
|
_, _ = s.vpn.loop.ApplyStatus(ctx, constants.Running)
|
2022-01-06 06:40:23 -05:00
|
|
|
s.vpn.healthyWait += *s.config.VPN.Addition
|
2021-08-18 22:01:04 +00:00
|
|
|
s.vpn.healthyTimer = time.NewTimer(s.vpn.healthyWait)
|
2021-07-18 03:17:48 +00:00
|
|
|
}
|