예제 #1
0
        /// <summary>
        /// Stop and remove a server from the cluster
        /// </summary>
        public bool Remove(string label)
        {
            if (!Servers.ContainsKey(label))
            {
                return(true);
            }

            OnBeforeStopEach?.Invoke();
            Servers[label].Stop();
            OnAfterStopEach?.Invoke();

            return(Servers.Remove(label));
        }
예제 #2
0
        /// <summary>
        /// Stops each server in the cluster
        /// </summary>
        public void StopAll()
        {
            OnBeforeStopAll?.Invoke();

            foreach (var server in Servers.Values.Where(server => server.IsListening))
            {
                OnBeforeStopEach?.Invoke();
                server.Stop();
                OnAfterStopEach?.Invoke();
            }

            OnAfterStopAll?.Invoke();
            Started = false;
        }
예제 #3
0
        /// <summary>
        /// Stop and remove a server from the cluster
        /// </summary>
        public bool Remove(string label)
        {
            if (!Servers.ContainsKey(label))
            {
                return(true);
            }
            var server = Get(label);

            if (Started)
            {
                OnBeforeStopEach?.Invoke(server);
                server.Stop();
                OnAfterStopEach?.Invoke(server);
            }

            return(Servers.Remove(label));
        }