protected override void OnServiceOpened(IServiceHost service)
        {
            var serviceInfoHelper = _container.Resolve <IServiceInfoHelper>();

            serviceInfoHelper.PrintServiceHostInfo(service.ServiceHost);
            //ServiceInfoHelperConsole.PrintServiceHostInfo(service.ServiceHost);
        }
示例#2
0
		public virtual void Initialize(IFabricRuntimeSettings settings)
		{
			this.WriteDebugMessage(string.Format("Initializing {0}", GetType().Name));

			if (settings.ServiceHost.Value == null)
			{
				throw new NoServiceHostConfiguredException("You must configure a service host.");
			}

			if (settings.HostedServices.Value == null || settings.HostedServices.Value.Count == 0)
			{
				throw new NoHostedServicesConfiguredException("You must configure hosted services.");
			}

			CurrentSettings = settings;

			try
			{
				_serviceHost = (IServiceHost)Container.Resolve(settings.ServiceHost.Value);
			}
			catch (ComponentNotFoundException e)
			{
				throw new ServiceHostNotResolvableException(
					string.Format("Unable to resolve service host of type {0} from container.", settings.ServiceHost.Value), e);
			}

			CurrentSettings = settings;

			this.WriteInfoMessage(string.Format("Initialized {0}.", GetType().Name));
		}
 protected ExCommsServiceInfo(IExecutorService executorService,
                              ExCommsHostingModuleType moduleType,
                              IEnumerable <IExCommsServerHostFactoryActivator> activators)
     : base(executorService)
 {
     _factory = new ExCommsServerHostFactoryActivatorFactory(executorService, moduleType, activators);
 }
示例#4
0
        public override void InitializeService(IServiceHost serviceHost)
        {
            // get a handle on the SettingsService
            SettingsService = this.ServiceProvider.GetService <SettingsService <LanguageServerSettings> >();
            Debug.Assert(SettingsService != null, "SettingsService instance not set");

            SettingsService.RegisterConfigChangeCallback(HandleDidChangeConfigurationNotification);

            // get a handle on the WorkspaceService
            WorkspaceService = this.ServiceProvider.GetService <WorkspaceService>();
            Debug.Assert(WorkspaceService != null, "WorkspaceService instance not set");

            // register a callback to handle document changes
            WorkspaceService.RegisterTextDocChangeCallback(HandleDidChangeTextDocumentNotification);

            // Register an initialization handler that retrieves the initial settings
            serviceHost.RegisterInitializeTask(async(parameters, context) =>
            {
                Logger.Instance.Write(LogLevel.Verbose, "Initializing service");

                context.SendEvent(
                    DidChangeConfigurationNotification <LanguageServerSettings> .Type,
                    new DidChangeConfigurationParams <LanguageServerSettings>
                {
                    Settings = new LanguageServerSettings()
                }
                    );

                await Task.FromResult(0);
            });
        }
 public override void Close(IServiceHost host)
 {
     foreach (ConnectorHandle handle in _handles)
     {
         handle.Close();
     }
 }
 protected ExCommsServiceInfo(IExecutorService executorService,
     ExCommsHostingModuleType moduleType,
     IEnumerable<IExCommsServerHostFactoryActivator> activators)
     : base(executorService)
 {
     _factory = new ExCommsServerHostFactoryActivatorFactory(executorService, moduleType, activators);
 }
示例#7
0
        /// <summary>
        /// Initialize the Source Monitor as a Service Extension.
        /// </summary>
        /// <param name="config">configuration </param>
        /// <param name="serviceHost">service host which init the extension</param>
        public void Initialize(IConfiguration config, IServiceHost serviceHost)
        {
            if (config == null || serviceHost == null)
            {
                throw new InitializeParameterEmtyException("parameter can't be null for initialize");
            }

            _configSetting = config;
            _serviceHost   = serviceHost;

            WatchSourceCollection watchSourcese = this.ConfigurationSetting.GetConfiguationData <WatchSourceCollection>("");

            List <ISourceWatcher> watchers = _serviceHost.GetFunctionExtensions <ISourceWatcher>(ExtensionCategory.WatchingExtension);

            foreach (WatchSource source in watchSourcese)
            {
                watchers.ForEach(delegate(ISourceWatcher watcher)
                {
                    if (watcher.IsAcceptedSource(source))
                    {
                        watcher.Watching(source);

                        watcher.RegisterEvent(this.MonitorSourceChangedEventHandler);
                    }
                });
            }

            _serviceHost.RunInBackground(this);
        }
示例#8
0
        public static IApplicationBuilder UseJimu(this IApplicationBuilder app, IServiceHost host)
        {
            Console.WriteLine();
            app.UseMiddleware <JimuHttpStatusCodeExceptionMiddleware>();
            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            });

            var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            JimuHttpContext.Configure(httpContextAccessor);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "JimuPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "JimuServices", action = "JimuPath" });
            });

            JimuClient.Host = host;
            return(app);
        }
示例#9
0
        public static IApplicationBuilder UseGateWay(this IApplicationBuilder app, IServiceHost host)
        {
            app.UseMiddleware <HttpStatusCodeExceptionMiddleware>();
            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            });

            IHttpContextAccessor httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            GateWayHttpContext.Configure(httpContextAccessor);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "handlerPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "Services", action = "ExecutePath" });
            });

            return(app);
        }
 public bool TryGetServiceHost(string servicePath, out IServiceHost serviceHost)
 {
     lock (_sync)
     {
         return(_serviceHosts.TryGetValue(servicePath, out serviceHost));
     }
 }
示例#11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddControllersAsServices();
            services.UseJimu();

            // inject controller
            this._containerBuilder.RegisterAssemblyTypes(typeof(ValuesController).GetTypeInfo().Assembly)
            .Where(t => typeof(Controller).IsAssignableFrom(t) &&
                   t.Name.EndsWith("Controller", StringComparison.Ordinal)).PropertiesAutowired();

            _containerBuilder.Populate(services);

            // start jimu client host;
            _host = new ServiceHostClientBuilder(_containerBuilder)
                    .UseInServerForDiscovery(new DotNettyAddress("127.0.0.1", 8007), new HttpAddress("127.0.0.1", 8008))
                    .UseDotNettyForTransfer()
                    .UseHttpForTransfer()
                    .UsePollingAddressSelector()
                    .UseServiceProxy(new[] { "IServices" })
                    .UseServerHealthCheck(1)
                    .SetDiscoveryAutoUpdateJobInterval(60)
                    .Build();

            return(this._host.Container.Resolve <IServiceProvider>());
            //return new AutofacServiceProvider(this._host.Container);
        }
示例#12
0
 public DefaultServiceStarter(IServiceHost serviceHost, IServiceConfiguration serviceConfiguration, TClient client)
 {
     Client      = client;
     ServiceHost = serviceHost;
     Environment = new Dictionary <string, object> {
         { Service.EnvironmentKeys.StartParameters, serviceConfiguration.StartParameters }
     };
 }
示例#13
0
        public void Configure(IServiceHost <NotificationEngine> host)
        {
            host.AddNamedPipeEndpoint(typeof(INotificationEngine), "absence:notification", configureBinding: binding => binding.UseDefaults());

            host.AddNetTcpEndpoint(typeof(INotificationEngine), 10003, hostname: _options.AnnouncedHostName, configureBinding: binding => binding.UseDefaults());

            host.AddMetadata(10103);
        }
        public void Open(IServiceHost host)
        {
            _factory = new NestedFrameServerProtocolFactory();

            host.Reactor.ListenStream(
                _factory, 1234
                );
        }
 protected void AddServiceHost(IServiceHost serviceHost, Uri endpointAddress)
 {
     ServiceHosts.Add(serviceHost.Name, new ServiceHostInfo
     {
         EndpointAddress = endpointAddress,
         ServiceHost     = serviceHost
     });
 }
        public void Configure(IServiceHost <StorageResourceAccess> host)
        {
            host.AddNamedPipeEndpoint(typeof(IStorageResourceAccess), "absence:storage", configureBinding: binding => binding.UseDefaults());

            host.AddNetTcpEndpoint(typeof(IStorageResourceAccess), 10001, hostname: _options.AnnouncedHostName, configureBinding: binding => binding.UseDefaults());

            host.AddMetadata(10101);
        }
示例#17
0
        public void Configure(IServiceHost <AbsenceManager> host)
        {
            host.AddNamedPipeEndpoint(typeof(IAbsenceManager), "absence:absence-manager", configureBinding: binding => binding.UseDefaults());

            host.AddNetTcpEndpoint(typeof(IAbsenceManager), 10002, hostname: _options.AnnouncedHostName, configureBinding: binding => binding.UseDefaults());

            host.AddMetadata(10102);
        }
        public void Open(IServiceHost host)
        {
            _host = host;
            _fileBuilders = new Dictionary<string,FileRebuilder>();

            _waitingChunks = new Queue<FileChunkMessage>();

            _timerHandle = host.Reactor.AddTimer(DateTime.Now, CheckForBuildTask, null);
        }
示例#19
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config       = new Config("LillTek.Datacenter.RouterService");
                Program.PerfCounters = null;    // $todo(jeff.lill): new PerfCounterSet(true,Const.RouterServicePerf,Const.RouterServiceName);

                // Service initialization

                this.serviceHost = serviceHost;

                try
                {
                    RootRouter rootRouter;
                    HubRouter  hubRouter;

                    switch (Program.Config.Get("Mode", "HUB").ToUpper())
                    {
                    case "ROOT":

                        SysLog.LogInformation("Router Service v{0}: Starting as ROOT", Helper.GetVersionString());
                        router = rootRouter = new RootRouter();
                        rootRouter.Start();
                        break;

                    case "HUB":
                    default:

                        SysLog.LogInformation("Router Service v{0}: Starting as HUB", Helper.GetVersionString());
                        router = hubRouter = new HubRouter();
                        hubRouter.Start();
                        break;
                    }

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
        public void Close(IServiceHost host)
        {
            //Clean up and delete any open files - possibly allow restart in future
            foreach (KeyValuePair<string, FileRebuilder> kvp in _fileBuilders)
            {
                kvp.Value.Dispose();
            }

            _waitingChunks.Clear();
        }
示例#21
0
        private void InvokeCallback(IServiceHost serviceHost, string name, string[] datas)
        {
            if (serviceHost.MethodDescriptors.ContainsKey(name) == false)
            {
                throw new InvalidOperationException();
            }
            var methodDescriptor = serviceHost.MethodDescriptors[name];
            var args             = this.serializer.DeserializeMany(methodDescriptor.ParameterTypes, datas);
            var instance         = this.descriptor.Callbacks[serviceHost];

            Task.Run(() => methodDescriptor.InvokeAsync(this.serviceContext, instance, args));
        }
示例#22
0
 /// <summary>
 /// Method to execute when the service starts.
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     // Start database server.
     _databaseServer = DatabaseServer.CreateInstance();
     _databaseServer.Open();
     // Start RESTful resource service.
     _resourceService = ServiceHost.CreateInstance<ResourceService>();
     _resourceService.Open();
     // Start RESTful project service.
     _projectService = ServiceHost.CreateInstance<ProjectService>();
     _projectService.Open();
 }
        public static async Task RunAsync(this IServiceHost host, CancellationToken ct = default(CancellationToken))
        {
            await host.StartAsync(ct);

            var cancelCompletionSource = new TaskCompletionSource <ConsoleCancelEventArgs>();

            Console.CancelKeyPress += (sender, args) =>
            {
                cancelCompletionSource.TrySetResult(args);
            };
            await cancelCompletionSource.Task;
        }
示例#24
0
 /// <summary>
 /// Method to execute when the service starts.
 /// </summary>
 /// <param name="args"></param>
 protected override void OnStart(string[] args)
 {
     // Start database server.
     _databaseServer = DatabaseServer.CreateInstance();
     _databaseServer.Open();
     // Start RESTful resource service.
     _resourceService = ServiceHost.CreateInstance <ResourceService>();
     _resourceService.Open();
     // Start RESTful project service.
     _projectService = ServiceHost.CreateInstance <ProjectService>();
     _projectService.Open();
 }
示例#25
0
        //public TaskCenter()
        //{
        //    _Enter(null);
        //}
        internal void _Enter(IServiceHost host)
        {
            this.host = host;

            if (null != ServiceCenter.instance)
            {
                throw new Exception("Duplicated TaskCenter component!");
            }

            ServiceCenter.instance = this;

            _Init();
        }
示例#26
0
        /// <summary>
        /// Starts the hosted service.
        /// </summary>
        public void Start()
        {
            if (host != null)
            {
                throw new InvalidOperationException("ServiceHost instances cannot be reused.");
            }

            SysLog.LogProvider = logProvider;

            host = new ApplicationServiceHost();
            host.Initialize(args, service, logProvider, true);
            service.Start(host, args);
        }
示例#27
0
        public void Close(IServiceHost host)
        {
            _queue.StopDequeuingToCallback();

            if (!_isFinished) _finishedEvent.Set();

            _finishedEvent.Close();

            _queue = null;
            _finishedEvent = null;
            _isFinished = true;
            _dequeuedObjects = null;
        }
示例#28
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();

                Program.Config = new Config(MsgQueueHandler.ConfigPrefix);
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Message Queue v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    handler = new MsgQueueHandler();
                    handler.Start(router, null, Program.PerfCounters, null);

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (handler != null)
                    {
                        handler.Stop();
                        handler = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
        public void Add(string servicePath, IServiceHost serviceHost)
        {
            lock (_sync)
            {
                IServiceHost host;
                if (_serviceHosts.TryGetValue(servicePath, out host))
                {
                    _logger.Error(
                        "The WebSocket service host with the specified path found.\npath: " + servicePath);
                    return;
                }

                _serviceHosts.Add(servicePath.UrlDecode(), serviceHost);
            }
        }
示例#30
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config = new Config("LillTek.Datacenter.DynDNSClient");
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Dynamic DNS Client v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    client = new DynDnsClient();
                    client.Open(router, new DynDnsClientSettings("LillTek.Datacenter.DynDNSClient"));

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (client != null)
                    {
                        client.Close();
                        client = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
示例#31
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config       = new Config(ConfigServiceHandler.ConfigPrefix);
                Program.PerfCounters = null;    // $todo(jeff.lill): new PerfCounterSet(true,Const.ConfigServicePerf,Const.ConfigServiceName);

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Config Service v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    handler = new ConfigServiceHandler();
                    handler.Start(router, null, null, null);

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (handler != null)
                    {
                        handler.Stop();
                        handler = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
        private static void StopService(IServiceHost serviceHost, string errorMessage)
        {
            if (!serviceHost.IsServiceRunning)
            {
                return;
            }

            try
            {
                serviceHost.StopService();
            }
            catch (Exception exception)
            {
                HandleException(errorMessage, exception);
            }
        }
        public ServiceMainForm(IExecutorService executorService, IServiceHost serviceHost)
        {
            InitializeComponent();
            SetTagProperty();
            this.ResolveResources();

            _normalFont = this.Font;
            _boldFont   = new Font(this.Font, FontStyle.Bold);

            _queue          = ProducerConsumerQueueFactory.Create <LogItem>(executorService, -1);
            _queue.Dequeue += OnQueue_Dequeue;

            Log.GlobalWriteToExternalLog += new WriteToExternalLogHandler(Log_WriteToExternalLog);
            _setStatus = new SetStatusHandler(this.SetStatus);

            _serviceHost = serviceHost;
        }
        public ServiceMainForm(IExecutorService executorService, IServiceHost serviceHost)
        {
            InitializeComponent();
            SetTagProperty();
            this.ResolveResources();

            _normalFont = this.Font;
            _boldFont = new Font(this.Font, FontStyle.Bold);

            _queue = ProducerConsumerQueueFactory.Create<LogItem>(executorService, -1);
            _queue.Dequeue += OnQueue_Dequeue;

            Log.GlobalWriteToExternalLog += new WriteToExternalLogHandler(Log_WriteToExternalLog);
            _setStatus = new SetStatusHandler(this.SetStatus);

            _serviceHost = serviceHost;
        }
        public static bool UnregisterService(this IServiceHost serviceHost, params Type[] services)
        {
            if (serviceHost is null)
            {
                return(false);
            }
            bool success = true;

            foreach (var service in services)
            {
                if (!serviceHost.UnregisterService(service))
                {
                    success = false;
                }
            }
            return(success);
        }
示例#36
0
        static void Main(string[] args)
        {
            IServiceHost host = null;

            // register as server
            var builder = new ServiceHostServerBuilder(new ContainerBuilder())
                          .UseLog4netLogger()
                          .LoadServices(new string[] { "Auth.IServices", "Auth.Services" })
                          .UseDotNettyForTransfer("127.0.0.1", 8000)
                          .UseConsulForDiscovery("127.0.0.1", 8500, "JimuService", $"127.0.0.1:8000")
                          .UseJoseJwtForOAuth <DotNettyAddress>(new JwtAuthorizationOptions
            {
                SecretKey         = "123456",
                ExpireTimeSpan    = new TimeSpan(3, 0, 0, 0),
                ValidateLifetime  = true,
                ServerIp          = "127.0.0.1",
                ServerPort        = 8000,
                TokenEndpointPath = "api/oauth/token?username=&password="******"username or password is incorrect.", "");
                    }
                    else
                    {
                        ctx.AddClaim("roles", member.Role);
                        ctx.AddClaim("member", Newtonsoft.Json.JsonConvert.SerializeObject(member));
                    }
                }),
            });

            using (host = builder.Build())
            {
                //InitProxyService();
                host.Run();
                while (true)
                {
                    Console.ReadKey();
                }
            }
        }
 internal ServiceController(
     ILogger logger,
     Func <string, ILogObserver> logWriterFactory,
     IOperationSequence bootstrapSequence,
     IOperationSequence sessionSequence,
     IServiceHost serviceHost,
     SessionContext sessionContext,
     ISystemConfigurationUpdate systemConfigurationUpdate)
 {
     this.logger                    = logger;
     this.logWriterFactory          = logWriterFactory;
     this.bootstrapSequence         = bootstrapSequence;
     this.sessionSequence           = sessionSequence;
     this.serviceHost               = serviceHost;
     this.sessionContext            = sessionContext;
     this.systemConfigurationUpdate = systemConfigurationUpdate;
 }
示例#38
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock) {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config = new Config("LillTek.GeoTracker.Service");
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("GeoTracker Service v{0} Start", Helper.GetVersionString());

                try {
                    router = new LeafRouter();
                    router.Start();

                    node = new GeoTrackerNode();
                    node.Start(router, GeoTrackerNode.ConfigPrefix, Program.PerfCounters, null);

                    state = ServiceState.Running;
                }
                catch (Exception e) {
                    if (node != null)
                    {
                        node.Stop();
                        node = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
示例#39
0
        static void Main(string[] args)
        {
            // Start database server.
            _databaseServer = DatabaseServer.CreateInstance();
            _databaseServer.Open();
            // Start RESTful resource service.
            _resourceService = ServiceHost.CreateInstance <ResourceService>();
            _resourceService.Open();
            // Start RESTful resource service.
            _projectService = ServiceHost.CreateInstance <ProjectService>();
            _projectService.Open();

            System.Console.WriteLine("Press enter to stop services...");
            System.Console.ReadLine();

            _projectService.Close();
            _resourceService.Close();
            _databaseServer.Close();
        }
示例#40
0
        static void Main(string[] args)
        {
            // Start database server.
            _databaseServer = DatabaseServer.CreateInstance();
            _databaseServer.Open();
            // Start RESTful resource service.
            _resourceService = ServiceHost.CreateInstance<ResourceService>();
            _resourceService.Open();
            // Start RESTful resource service.
            _projectService = ServiceHost.CreateInstance<ProjectService>();
            _projectService.Open();

            System.Console.WriteLine("Press enter to stop services...");
            System.Console.ReadLine();

            _projectService.Close();
            _resourceService.Close();
            _databaseServer.Close();
        }
示例#41
0
        public override void InitializeService(IServiceHost serviceHost)
        {
            serviceHost.SetAsyncEventHandler(DidChangeTextDocumentNotification.Type, HandleDidChangeTextDocumentNotification);
            serviceHost.SetAsyncEventHandler(DidOpenTextDocumentNotification.Type, HandleDidOpenTextDocumentNotification);
            serviceHost.SetAsyncEventHandler(DidCloseTextDocumentNotification.Type, HandleDidCloseTextDocumentNotification);

            // Register an initialization handler that sets the workspace path
            serviceHost.RegisterInitializeTask(async(parameters, context) =>
            {
                Logger.Instance.Write(LogLevel.Verbose, "Initializing workspace service");

                // Create a workspace that will handle state for the session
                Workspace = new Workspace(parameters.Capabilities);

                // we only support a single workspace path
                if (parameters.WorkspaceFolders != null)
                {
                    Workspace.WorkspacePath = parameters.WorkspaceFolders.First().Uri;
                }
                else
                {
                    Workspace.WorkspacePath = parameters.RootUri;
                }

                await Task.FromResult(0);
            });

            // Register a shutdown request that disposes the workspace
            serviceHost.RegisterShutdownTask(async(parameters, context) =>
            {
                Logger.Instance.Write(LogLevel.Verbose, "Shutting down workspace service");

                if (Workspace != null)
                {
                    Workspace.Dispose();
                    Workspace = null;
                }

                await Task.FromResult(0);
            });
        }
示例#42
0
        public void Open(IServiceHost host)
        {
            OnServiceOpen(host);

            if (_factory != null)
            {
                _factory.LostConnection -= new EventHandler<ExceptionEventArgs>(_factory_LostConnection);
                _factory.MessageReceived -= new EventHandler<MessageEventArgs>(_factory_MessageReceived);
                _factory.MessageSending -= new EventHandler<MessageEventArgs>(_factory_MessageSending);
            }

            _factory = CreateFactory();

            _factory.LostConnection += new EventHandler<ExceptionEventArgs>(_factory_LostConnection);

            _factory.MessageReceived += new EventHandler<MessageEventArgs>(_factory_MessageReceived);

            _factory.MessageSending += new EventHandler<MessageEventArgs>(_factory_MessageSending);

            ConnectReactor(host);
        }
示例#43
0
 public void Close(IServiceHost host)
 {
 }
        public void Open(IServiceHost host)
        {
            _factory = new MessageClientProtocolFactory();

            host.Reactor.ConnectStream(_factory, IPAddress.Parse("127.0.0.1"), 1969);
        }
示例#45
0
 public void Open(IServiceHost host)
 {
 }
示例#46
0
        public void Open(IServiceHost host)
        {
            _queue = new ReactorQueue<int>(_capacity);
            _finishedEvent = new ManualResetEvent(false);
            _isFinished = false;
            _dequeuedObjects = new List<int>();

            _queue.StartDequeuingToCallback(host.Reactor, DequeueCallback);
        }
示例#47
0
 public bool TryGetServiceHost(string absPath, out IServiceHost svcHost)
 {
     return _svcHosts.TryGetValue(absPath, out svcHost);
 }
        protected override void ConnectReactor(IServiceHost host)
        {
            ClientFactory.ProtocolMadeConnection += new EventHandler(ClientFactory_ProtocolMadeConnection);

            host.Reactor.ConnectStream(Factory, Settings.ServerAddress, Settings.Port);
        }
        public void Open(IServiceHost host)
        {
            _host = host;

            _server = new RemotingTestServerProtocol();

            host.Reactor.ListenStream(new NoArgumentProtocolFactory<RemotingTestServerProtocol>(), 1337);

            _queue.Open(host);
        }
        public void Close(IServiceHost host)
        {
            _queue.Close(host);

            _host = null;
        }
 public void Open(IServiceHost host)
 {
     host.Reactor.ConnectStream(_factory, IPAddress.Parse("127.0.0.1"), 1809);
 }
示例#52
0
 public void Open(IServiceHost host)
 {
     host.Reactor.ListenStream(new ChatroomServerProtocolFactory(_settings, _plugins), _settings.Port);
 }
示例#53
0
        bool OpenListOfServices(List<IService> services, IServiceHost host, 
            ServiceExceptionKind openExceptionKind, ServiceExceptionKind openAbortExceptionKind)
        {
            Stack<IService> startedServices = new Stack<IService>();

            try
            {
                foreach (IService service in services)
                {
                    service.Open(host);

                    startedServices.Push(service);
                }

                return true;
            }
            catch (Exception ex)
            {
                while (startedServices.Count > 0)
                {
                    IService serviceToShutdown = startedServices.Pop();

                    try
                    {
                        serviceToShutdown.Close(host);
                    }
                    catch (Exception nestedEx)
                    {
                        if (UnhandledException != null) UnhandledException(this,
                            new ServiceExceptionEventArgs(openAbortExceptionKind, nestedEx));
                    }
                }

                if (UnhandledException != null) UnhandledException(this,
                    new ServiceExceptionEventArgs(openExceptionKind, ex));

                return false;
            }
        }
        protected override void OnServiceOpen(IServiceHost host)
        {
            _rebuilderService = new FileRebuilderService(Settings);

            _host = new ServiceHost();

            _host.AddService(_rebuilderService);

            _host.StartServiceHost();
            _host.OpenServices();
        }
示例#55
0
 public void Add(string absPath, IServiceHost svcHost)
 {
     _svcHosts.Add(absPath.UrlDecode(), svcHost);
 }
        public override void Close(IServiceHost host)
        {
            ClientFactory.LoseConnection();

            _host.CloseServices();
            _host.StopServiceHost();
        }
        public void Open(IServiceHost host)
        {
            _reactor = host.Reactor;

            _controlConnector = host.Reactor.ListenStream(new RemoteCaptureProtocolFactory(this), _listenPort);
        }
        public void Close(IServiceHost host)
        {
            _controlConnector.Close();

            _reactor = null;
        }
 public void Open(IServiceHost host)
 {
     host.Reactor.BindDatagram(new UdpCaptureSourceProtocolFactory(_remoteCaptureService), _listenPort);
 }
 public ExCommsServiceBase(IServiceHost factory, string serviceName)
 {
     _factory = factory;
     this.ServiceName = serviceName;
 }