Example #1
0
        /// <inheritdoc />
        /// <summary> 启动服务 </summary>
        /// <param name="serviceAddress">主机终结点。</param>
        /// <returns>一个任务。</returns>
        public override Task Start(ServiceAddress serviceAddress)
        {
            serviceAddress.Protocol = Constants.Protocol;
            serviceAddress.Codec    = Constants.Codec;
            try
            {
                Task.Factory.StartNew(async() =>
                {
                    await MicroListener.Start(serviceAddress);
                });

                if (_logger.IsEnabled(LogLevel.Information))
                {
                    _logger.LogInformation(
                        $"服务已启动:{serviceAddress},Gzip:{serviceAddress.Gzip},Codec:{Constants.Codec},Protocol:{Constants.Protocol}");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
            }
            var assemblies = _entryFactory.GetContracts();

            return(_serviceRegister.Regist(assemblies, serviceAddress));
        }
Example #2
0
        /// <summary> 停止服务 </summary>
        /// <returns></returns>
        public override async Task Stop()
        {
            await _serviceRegister.Deregist();

            await MicroListener.Stop();

            Console.WriteLine("Service Stoped");
        }
Example #3
0
        public override async Task Stop()
        {
            await _serviceRegister.Deregist();

            await MicroListener.Stop();

            _logger.Info("Micro Host Stoped");
        }
Example #4
0
        /// <inheritdoc />
        /// <summary> 启动微服务 </summary>
        /// <param name="serviceAddress">主机终结点。</param>
        /// <returns>一个任务。</returns>
        public override async Task Start(ServiceAddress serviceAddress)
        {
            try
            {
                await MicroListener.Start(serviceAddress);

                _logger.Info("Micro Host Started");
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
            }

            var assemblies = _entryFactory.GetServices();
            await _serviceRegister.Regist(assemblies, serviceAddress);
        }
Example #5
0
        /// <inheritdoc />
        /// <summary> 启动服务 </summary>
        /// <param name="serviceAddress">主机终结点。</param>
        /// <returns>一个任务。</returns>
        public override Task Start(ServiceAddress serviceAddress)
        {
            try
            {
                Task.Factory.StartNew(async() =>
                {
                    await MicroListener.Start(serviceAddress);
                });
                Console.WriteLine($"Service Start At {serviceAddress}");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
            }

            var assemblies = _entryFactory.GetContracts();

            serviceAddress.Protocol = _protocol;
            return(_serviceRegister.Regist(assemblies, serviceAddress));
        }
Example #6
0
        /// <inheritdoc />
        /// <summary> 启动微服务 </summary>
        /// <param name="serviceAddress">主机终结点。</param>
        /// <returns>一个任务。</returns>
        public override Task Start(ServiceAddress serviceAddress)
        {
            try
            {
                Task.Factory.StartNew(async() =>
                {
                    await MicroListener.Start(serviceAddress);
                });
                _logger.LogInformation("Micro Host Started");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, ex.Message);
            }

            var assemblies = _entryFactory.GetServices();

            serviceAddress.Protocol = Constants.Protocol;
            return(_serviceRegister.Regist(assemblies, serviceAddress));
        }