Beispiel #1
0
        public void Dispose()
        {
            if (Disposed)
            {
                return;
            }
            lock (this)
            {
                if (Disposed)
                {
                    return;
                }

                Disposed = true;
                var ea = new ExceptionAggregator("Failed to properly close RavenServer");

                ea.Execute(() => AdminConsolePipe?.Dispose());
                ea.Execute(() => LogStreamPipe?.Dispose());
                ea.Execute(() => Metrics?.Dispose());
                ea.Execute(() => _webHost?.Dispose());
                if (_tcpListenerStatus != null)
                {
                    ea.Execute(() => CloseTcpListeners(_tcpListenerStatus.Listeners));
                }

                ea.Execute(() => ServerStore?.Dispose());
                ea.Execute(() => ServerMaintenanceTimer?.Dispose());
                ea.Execute(() => AfterDisposal?.Invoke());

                ea.ThrowIfNeeded();
            }
        }
Beispiel #2
0
        public void Dispose()
        {
            if (Disposed)
            {
                return;
            }
            Disposed = true;
            Metrics?.Dispose();
            _webHost?.Dispose();
            if (_tcpListenerTask != null)
            {
                if (_tcpListenerTask.IsCompleted)
                {
                    CloseTcpListeners(_tcpListenerTask.Result.Listeners);
                }
                else
                {
                    if (_tcpListenerTask.Exception != null)
                    {
                        if (_tcpLogger.IsInfoEnabled)
                        {
                            _tcpLogger.Info("Cannot dispose of tcp server because it has errored", _tcpListenerTask.Exception);
                        }
                    }
                    else
                    {
                        _tcpListenerTask.ContinueWith(t =>
                        {
                            CloseTcpListeners(t.Result.Listeners);
                        }, TaskContinuationOptions.OnlyOnRanToCompletion);
                    }
                }
            }

            ServerStore?.Dispose();
            ServerMaintenanceTimer?.Dispose();
            _latestVersionCheck?.Dispose();
        }