protected override void OnStop() { Try(nameof(OnStop), () => { if (_server != null) { GrpcServerUtils.GracefullyStop(_server); } }); }
private void _timer_Elapsed(object sender, ElapsedEventArgs e) { if (_health == null) { return; } if (_health.IsAnyServiceUnhealthy()) { _health = null; _msg.Warn("Shutting down due to unhealthy service..."); GrpcServerUtils.GracefullyStop(_server); // This allows the auto-restart to kick in: Environment.Exit(-1); } }