Exemplo n.º 1
0
        public void Run()
        {
            try
            {
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Version", ProcessHelper.GetCurrentProcessVersion());
                this.tracer.RelatedEvent(EventLevel.Informational, $"{nameof(GSDService)}_{nameof(this.Run)}", metadata);

                this.repoRegistry = new RepoRegistry(
                    this.tracer,
                    new PhysicalFileSystem(),
                    this.serviceDataLocation,
                    new GSDMountProcess(this.tracer),
                    new NotificationHandler(this.tracer));
                this.repoRegistry.Upgrade();
                this.requestHandler = new RequestHandler(this.tracer, EtwArea, this.repoRegistry);

                string pipeName = GSDPlatform.Instance.GetGSDServiceNamedPipeName(this.serviceName);
                this.tracer.RelatedInfo("Starting pipe server with name: " + pipeName);

                using (NamedPipeServer pipeServer = NamedPipeServer.StartNewServer(
                           pipeName,
                           this.tracer,
                           this.requestHandler.HandleRequest))
                {
                    this.CheckEnableGitStatusCacheTokenFile();

                    // Start product upgrade timer only after attempting to enable prjflt.
                    // On Windows server (where PrjFlt is not inboxed) this helps avoid
                    // a race between TryEnablePrjFlt() and installer pre-check which is
                    // performed by UpgradeTimer in parallel.
                    this.productUpgradeTimer.Start();

                    this.serviceStopped.WaitOne();
                }
            }
            catch (Exception e)
            {
                this.LogExceptionAndExit(e, nameof(this.Run));
            }
        }
Exemplo n.º 2
0
        private static GSDService CreateService(JsonTracer tracer, string[] args)
        {
            string serviceName = args.FirstOrDefault(arg => arg.StartsWith(GSDService.ServiceNameArgPrefix, StringComparison.OrdinalIgnoreCase));

            if (serviceName != null)
            {
                serviceName = serviceName.Substring(GSDService.ServiceNameArgPrefix.Length);
            }
            else
            {
                serviceName = GSDConstants.Service.ServiceName;
            }

            GSDPlatform gvfsPlatform = GSDPlatform.Instance;

            string logFilePath = Path.Combine(
                gvfsPlatform.GetDataRootForGSDComponent(serviceName),
                GSDConstants.Service.LogDirectory);

            Directory.CreateDirectory(logFilePath);

            tracer.AddLogFileEventListener(
                GSDEnlistment.GetNewGSDLogFileName(logFilePath, GSDConstants.LogFileTypes.Service),
                EventLevel.Informational,
                Keywords.Any);

            string       serviceDataLocation = gvfsPlatform.GetDataRootForGSDComponent(serviceName);
            RepoRegistry repoRegistry        = new RepoRegistry(
                tracer,
                new PhysicalFileSystem(),
                serviceDataLocation,
                new GSDMountProcess(tracer),
                new NotificationHandler(tracer));

            return(new GSDService(tracer, serviceName, repoRegistry));
        }