Exemple #1
0
        public ServiceEndpointDescription StartBasicHttpHost <TServiceType, TServiceInterfaceType>(string name, string description)
        {
            Platform.Log(LogLevel.Info, "Starting WCF Shred {0}...", name);

            if (_serviceEndpointDescriptions.ContainsKey(name))
            {
                throw new Exception(String.Format("The service endpoint '{0}' already exists.", name));
            }

            ServiceEndpointDescription sed =
                WcfHelper.StartBasicHttpHost <TServiceType, TServiceInterfaceType>(name, description, SharedHttpPort, ServiceAddressBase);

            _serviceEndpointDescriptions[name] = sed;

            Platform.Log(LogLevel.Info, "WCF Shred {0} is listening at {1}.", name, sed.ServiceHost.Description.Endpoints[0].Address);

            return(sed);
        }
Exemple #2
0
        /// <summary>
        /// Stops the running ShredHost.
        /// </summary>
        /// <returns>true - if the ShredHost is running, false - if the ShredHost is stopped.</returns>
        public static bool Stop()
        {
            lock (_lockObject)
            {
                if (RunningState.Stopped == _runningState || RunningState.Transition == _runningState)
                {
                    return(RunningState.Running == _runningState);
                }

                _runningState = RunningState.Transition;
            }

            // correct sequence should be to stop the WCF host so that we don't
            // receive any more incoming requests
            Platform.Log(LogLevel.Info, "ShredHost stop request received");

            if (_shredHostWCFInitialized)
            {
                try
                {
                    WcfHelper.StopHost(_sed);
                    Platform.Log(LogLevel.Info, "The ShredHost WCF service has stopped.");
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Error, e);
                }
            }

            StopShreds();
            Platform.Log(LogLevel.Info, "Completing ShredHost stop.");

            _shredInfoList.Clear();
            lock (_lockObject)
            {
                _runningState = RunningState.Stopped;
            }

            return(RunningState.Running == _runningState);
        }