Esempio n. 1
0
        /// <summary>
        /// Stops the WCF Server.
        /// </summary>
        public void Stop()
        {
            Log.Info("Stopping Server");

            if (_mainHost != null)
            {
                _mainHost.Close();
            }
            if (_bootstrapperHost != null)
            {
                _bootstrapperHost.Close();
            }

            if (serviceThread != null && !serviceThread.Join(5000))
            {
                Log.Info("Server did not stop after 5s, aborting");
                serviceThread.Abort();
            }
            serviceThread = null;

            // Work around AppDomainUnloadedException due to Race with WCF's _host.Close()
            // See https://bugs.launchpad.net/nunitv2/+bug/423611
            Log.Info("Waiting for WCF to disappear");
            Thread.Sleep(3000);

            serverStarted.Close();

            Log.Info("Server stopped");
        }
Esempio n. 2
0
 /// <summary>
 /// Stop hosting services.
 /// </summary>
 public void Stop()
 {
     if (connected && host != null && host.State != CommunicationState.Closed && host.State != CommunicationState.Closing)
     {
         host.Close();
     }
 }
Esempio n. 3
0
        void IAppServerComponent.Deactivate()
        {
            try
            {
                if (_serviceHost == null)
                {
                    throw new InvalidOperationException("The service host has not been initialized");
                }

                if (this._serviceHost.State == CommunicationState.Closed || this._serviceHost.State == CommunicationState.Created)
                {
                    return;
                }

                if (this._serviceHost.State == CommunicationState.Opened || this._serviceHost.State == CommunicationState.Opening)
                {
                    _serviceHost.Close();
                    this._logger.Info("The WCF Service Host '{0}' has been closed successfully", this._name);
                }
            }
            catch (Exception e)
            {
                this._logger.Error(e, this._name);
            }
        }
Esempio n. 4
0
        protected override void OnDeactivate(bool close)
        {
            _eventAggregator?.Unsubscribe(this);

            if (_serviceHost?.State == CommunicationState.Opened)
            {
                _serviceHost.Close();
            }

            QuartzApkDkReglamentRegSh.Shutdown();

            base.OnDeactivate(close);
        }
Esempio n. 5
0
        public Loader()
        {
            if (_isLoaded)
            {
                return;
            }
            _isLoaded = true;

            //Debugger.Launch();
            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            if (AppDomain.CurrentDomain.GetAssemblies().Any(p => StringComparer.OrdinalIgnoreCase.Equals(p.GetName().Name, "log4net")))
            {
                InitializeLogging();
            }
            LoggingTraceListener.Initialize();

            var loadedEvent = new AutoResetEvent(false);

            var thread = new Thread(() =>
            {
                Thread.CurrentThread.Name         = "Debug thread for Rain";
                Thread.CurrentThread.IsBackground = true;

                ServiceHostBase serviceHost = null;
                try
                {
                    serviceHost = LoadService <IDebugService, DebugService>();
                    serviceHost.Open();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.GetDescription());
                }

                loadedEvent.Set();

                try
                {
                    Thread.Sleep(Timeout.Infinite);
                }
                catch
                {
                    serviceHost.Close();
                }
            });

            thread.Start();
            loadedEvent.WaitOne();
            loadedEvent.Dispose();
        }
 public void Stop()
 {
     try
     {
         dealingServiceHost.Close();
         dealingSearchServiceHost.Close();
     }
     catch (Exception)
     {
         dealingServiceHost.Abort();
         dealingSearchServiceHost.Abort();
         throw;
     }
 }
Esempio n. 7
0
        private static void CloseServiceHost([CanBeNull] ServiceHostBase host)
        {
            if (host == null)
            {
                return;
            }

            host.Faulted -= ServiceHost_Faulted;
            host.UnknownMessageReceived -= ServiceHost_UnknownMessageReceived;

            if (host.State == CommunicationState.Opened)
            {
                host.Close();

                _Logger.Info("سرویس پایا بسته شد");
            }
        }
Esempio n. 8
0
 public void Stop()
 {
     Console.WriteLine(_serviceName + " stopping...");
     try
     {
         if (_serviceHost == null)
         {
             return;
         }
         _serviceHost.Close();
         _serviceHost = null;
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine("Caught exception while stopping " + _serviceName + ": " + ex);
     }
     finally
     {
         Console.WriteLine(_serviceName + " stopped...");
     }
 }
Esempio n. 9
0
 public void Stop()
 {
     _wcfEndPoint.Close();
 }
Esempio n. 10
0
 public void Close()
 {
     host.Close();
     host = null;
 }
Esempio n. 11
0
        public void Start()
        {
            Console.WriteLine(_serviceName + " starting...");
            var openSucceeded = false;

            try
            {
                _serviceHost?.Close();

                // ReSharper disable once AssignNullToNotNullAttribute
                _serviceHost =
                    new DefaultServiceHostFactory().CreateServiceHost(
                        typeof(ICurrencyRatesApiService).AssemblyQualifiedName, new Uri[] { });
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Caught exception while creating " + _serviceName + ": " + e);
                return;
            }

            try
            {
                _serviceHost?.Open();
                openSucceeded = true;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Caught exception while starting " + _serviceName + ": " + ex);
            }
            finally
            {
                if (!openSucceeded)
                {
                    _serviceHost?.Abort();
                }
            }

            if (_serviceHost != null && _serviceHost.State == CommunicationState.Opened)
            {
                Console.WriteLine(_serviceName + " started");
            }
            else
            {
                Console.WriteLine(_serviceName + " failed to open");
                var closeSucceeded = false;
                try
                {
                    _serviceHost?.Close();
                    closeSucceeded = true;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("{0} failed to close: {1}", _serviceName, ex);
                }
                finally
                {
                    if (!closeSucceeded)
                    {
                        _serviceHost?.Abort();
                    }
                }
            }
        }
Esempio n. 12
0
 public void Dispose()
 {
     _host.Close();
 }