Пример #1
0
        public void Run()
        {
            try
            {
                this.repoRegistry = new RepoRegistry(this.tracer, new PhysicalFileSystem(), this.serviceDataLocation);
                this.repoRegistry.Upgrade();
                this.productUpgradeTimer.Start();
                string pipeName = this.serviceName + ".Pipe";
                this.tracer.RelatedInfo("Starting pipe server with name: " + pipeName);

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

                    using (ITracer activity = this.tracer.StartActivity("EnsurePrjFltHealthy", EventLevel.Informational))
                    {
                        string error;
                        EnableAndAttachProjFSHandler.TryEnablePrjFlt(activity, out error);
                    }

                    this.serviceStopped.WaitOne();
                }
            }
            catch (Exception e)
            {
                this.LogExceptionAndExit(e, nameof(this.Run));
            }
        }
Пример #2
0
        private static GVFSService CreateService(JsonTracer tracer, string[] args)
        {
            string serviceName = args.FirstOrDefault(arg => arg.StartsWith(GVFSService.ServiceNameArgPrefix, StringComparison.OrdinalIgnoreCase));

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

            GVFSPlatform gvfsPlatform = GVFSPlatform.Instance;

            string logFilePath = Path.Combine(
                gvfsPlatform.GetDataRootForGVFSComponent(serviceName),
                GVFSConstants.Service.LogDirectory);

            Directory.CreateDirectory(logFilePath);

            tracer.AddLogFileEventListener(
                GVFSEnlistment.GetNewGVFSLogFileName(logFilePath, GVFSConstants.LogFileTypes.Service),
                EventLevel.Informational,
                Keywords.Any);

            string       serviceDataLocation = gvfsPlatform.GetDataRootForGVFSComponent(serviceName);
            RepoRegistry repoRegistry        = new RepoRegistry(
                tracer,
                new PhysicalFileSystem(),
                serviceDataLocation,
                new GVFSMountProcess(tracer));

            return(new GVFSService(tracer, serviceName, repoRegistry));
        }
        public void Run()
        {
            try
            {
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Version", ProcessHelper.GetCurrentProcessVersion());
                this.tracer.RelatedEvent(EventLevel.Informational, $"{nameof(GVFSService)}_{nameof(this.Run)}", metadata);

                this.repoRegistry = new RepoRegistry(
                    this.tracer,
                    new PhysicalFileSystem(),
                    this.serviceDataLocation,
                    new GVFSMountProcess(this.tracer),
                    this.notificationHandler);
                this.repoRegistry.Upgrade();
                this.requestHandler = new WindowsRequestHandler(this.tracer, EtwArea, this.repoRegistry);

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

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

                    using (ITracer activity = this.tracer.StartActivity("EnsurePrjFltHealthy", EventLevel.Informational))
                    {
                        // Make a best-effort to enable PrjFlt. Continue even if it fails.
                        // This will be tried again when user attempts to mount an enlistment.
                        string error;
                        EnableAndAttachProjFSHandler.TryEnablePrjFlt(activity, out error);
                    }

                    // 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));
            }
        }
Пример #4
0
 public void Run()
 {
     try
     {
         this.repoRegistry = new RepoRegistry(this.tracer, this.serviceDataLocation);
         this.repoRegistry.Upgrade();
         string pipeName = this.serviceName + ".Pipe";
         this.tracer.RelatedInfo("Starting pipe server with name: " + pipeName);
         using (NamedPipeServer pipeServer = NamedPipeServer.StartNewServer(pipeName, this.tracer, this.HandleRequest))
         {
             this.serviceStopped.WaitOne();
         }
     }
     catch (Exception e)
     {
         this.LogExceptionAndExit(e, nameof(this.Run));
     }
 }
Пример #5
0
        public void Run()
        {
            try
            {
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Version", ProcessHelper.GetCurrentProcessVersion());
                this.tracer.RelatedEvent(EventLevel.Informational, $"{nameof(GVFSService)}_{nameof(this.Run)}", metadata);

                this.repoRegistry = new RepoRegistry(
                    this.tracer,
                    new PhysicalFileSystem(),
                    Path.Combine(GVFSPlatform.Instance.GetCommonAppDataRootForGVFS(), this.serviceName),
                    new GVFSMountProcess(this.tracer),
                    this.notificationHandler);
                this.repoRegistry.Upgrade();
                this.requestHandler = new WindowsRequestHandler(this.tracer, EtwArea, this.repoRegistry);

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

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

                    using (ITracer activity = this.tracer.StartActivity("EnsurePrjFltHealthy", EventLevel.Informational))
                    {
                        // Make a best-effort to enable PrjFlt. Continue even if it fails.
                        // This will be tried again when user attempts to mount an enlistment.
                        string error;
                        EnableAndAttachProjFSHandler.TryEnablePrjFlt(activity, out error);
                    }

                    this.serviceStopped.WaitOne();
                }
            }
            catch (Exception e)
            {
                this.LogExceptionAndExit(e, nameof(this.Run));
            }
        }
Пример #6
0
        public GVFSService(JsonTracer tracer)
        {
            string logFilePath = Path.Combine(
                GVFSPlatform.Instance.GetDataRootForGVFSComponent(GVFSConstants.Service.ServiceName),
                GVFSConstants.Service.LogDirectory);

            Directory.CreateDirectory(logFilePath);

            this.tracer = tracer;
            this.tracer.AddLogFileEventListener(
                GVFSEnlistment.GetNewGVFSLogFileName(logFilePath, GVFSConstants.LogFileTypes.Service),
                EventLevel.Verbose,
                Keywords.Any);

            this.serviceName    = GVFSConstants.Service.ServiceName;
            this.serviceStopped = new ManualResetEvent(false);
            this.serviceThread  = new Thread(this.ServiceThreadMain);
            this.repoRegistry   = new RepoRegistry(
                this.tracer,
                new PhysicalFileSystem(),
                GVFSPlatform.Instance.GetDataRootForGVFSComponent(this.serviceName));
            this.requestHandler = new RequestHandler(this.tracer, EtwArea, this.repoRegistry);
        }
Пример #7
0
        public void Run()
        {
            try
            {
                this.repoRegistry = new RepoRegistry(this.tracer, this.serviceDataLocation);
                using (ITracer activity = this.tracer.StartActivity("StartUp", EventLevel.Informational))
                {
                    this.repoRegistry.AutoMountRepos();
                    this.repoRegistry.TraceStatus();
                }

                string pipeName = this.serviceName + ".Pipe";
                this.tracer.RelatedInfo("Starting pipe server with name: " + pipeName);
                using (NamedPipeServer pipeServer = NamedPipeServer.StartNewServer(pipeName, this.tracer, this.HandleRequest))
                {
                    this.serviceStopped.WaitOne();
                }
            }
            catch (Exception e)
            {
                this.LogExceptionAndExit(e, nameof(this.Run));
            }
        }