Example #1
0
            public void Run(
                string workerRoleAssembly,
                string configurationPath,
                string serviceDefinitionPath,
                string roleName,
                bool useHostedStorage)
            {
                var roleDirectory = Path.GetDirectoryName(workerRoleAssembly);

                if (string.IsNullOrWhiteSpace(roleDirectory))
                {
                    throw new ArgumentException("The worker role assembly must be in a specified directory.");
                }
                Directory.SetCurrentDirectory(roleDirectory);


                lock (gate)
                {
                    // as hoststub is called asynchronously, it it possible that shutdown has already been requested
                    // by the time we reach this point.
                    if (_cancellationTokenSource != null && _cancellationTokenSource.IsCancellationRequested)
                    {
                        return;
                    }

                    var getMethod = typeof(LightBlueThreadControl).GetMethod("get_CancellationTokenSource", BindingFlags.NonPublic | BindingFlags.Static);
                    _cancellationTokenSource = (CancellationTokenSource)getMethod.Invoke(null, null);
                }

                var runner = new HostRunner();

                runner.Run(workerRoleAssembly, configurationPath, serviceDefinitionPath, roleName, useHostedStorage);
            }
Example #2
0
 static void Main(string[] args)
 {
     var runner = new HostRunner("DemoService_QuickStartApi", new ListenerInfo
     {
         Port = 8053
     });
     var exit = runner.RunWebService();
 }
Example #3
0
 static void Main(string[] args)
 {
     var runner = new HostRunner("DemoService_BackgroundTask", new ListenerInfo
     {
         Port = 8052
     });
     var exit = runner.RunCompoundService(obj => Console.WriteLine($"The time is: {DateTime.Now:T}"), null, 5000);
 }
Example #4
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            var componenModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(false);

            Assumes.Present(componenModel);
            Workspace = componenModel.GetService <VisualStudioWorkspace>();

            string hostBasePath = Path.Combine(
                Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) !,
                "Host");

            HostRunner = HostRunner.GetHostRunner(hostBasePath, TargetFramework.Net5Plus, Platform.x64,
#if DEBUG
                                                  debug: true, waitForDebugger: false
#else
                                                  debug: false, waitForDebugger: false
#endif
                                                  );

            HostRunner.MessageReceived +=
                message => JoinableTaskFactory.Run(
                    async() => await OutWriter.WriteLineAsync($"HOST ({HostRunner.Id}): " + message));

            var mcs = (OleMenuCommandService) await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(false);

            Assumes.Present(mcs);

            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            OutWriter = new OutputWindowTextWriter(GetOutputPane(PackageGuids.OutputWindowPane, "Layout Analyzer"));

            mcs.AddCommand(new MenuCommand(
                               ShowLayoutWindow,
                               new CommandID(PackageGuids.CommandSet, PackageIds.LayoutWindowCommand)));
            mcs.AddCommand(new MenuCommand(
                               Analyze,
                               new CommandID(PackageGuids.ContextMenuCommandSet, PackageIds.AnalyzeCommand)));

            DTE = (DTE2) await GetServiceAsync(typeof(SDTE));

            Assumes.Present(DTE);
            FontAndColorStorage = (IVsFontAndColorStorage) await GetServiceAsync(typeof(SVsFontAndColorStorage));

            Assumes.Present(FontAndColorStorage);
            //Solution = (IVsSolution)await GetServiceAsync(typeof(SVsSolution));
            //SolutionEventSink = await SolutionEventSink.SubscribeAsync();
            //RunningDocumentTable = (IVsRunningDocumentTable)await GetServiceAsync(typeof(SVsRunningDocumentTable));
            //RunningDocumentTableEventSink = await RunningDocumentTableEventSink.SubscribeAsync();
            TextManager = (IVsTextManager) await GetServiceAsync(typeof(SVsTextManager));

            Assumes.Present(TextManager);
            TextManagerEventSink = await TextManagerEventSink.SubscribeAsync();
        }
Example #5
0
 private static async Task <int> Main(string[] args)
 {
     return(await HostRunner.Create(args).Configure(
                config => config
                .AddSystemServices(
                    fileSystemOptions: async(options) => {
         options.SetDataPath(DefaultPath.Application);
         options.CreateLockFile = true;
         await Task.CompletedTask;
     }
                    )
                .AddUtility()
                .AddAppWorker <Program>()
                ).Build().RunAsync());
 }
Example #6
0
 static void Main(string[] args)
 {
     var runner = new HostRunner <CustomStartup>("DemoService", new ListenerInfo
     {
         Port = 8050
     },
                                                 new ListenerInfo
     {
         AllowInvalidCert = true,
         Port             = 8051,
         SslCertStoreName = StoreName.My,
         SslCertSubject   = "CN=ec2-3-104-124-78.ap-southeast-2.compute.amazonaws.com",
         UseTls           = true
     });
     var exit = runner.RunWebService(LogEventLevel.Debug);
 }
Example #7
0
 private static async Task <int> Main(string[] args)
 {
     return(await HostRunner.Create(args).Configure(
                config => {
         config
         .AddSystemServices(
             fileSystemOptions: async(options) => {
             options.SetDataPath(DefaultPath.Application);
             options.CreateLockFile = false;
             await Task.CompletedTask;
         },
             settingsSystemOptions: async(options) => {
             options.CreateNewSettings = ()
                                         => new CustomSettings(new EnvironmentSettings()
             {
                 OutputReadableXML = false,
                 Locale = "en",
                 EnableLogging = true
             });
             await Task.CompletedTask;
         },
             commandLineOptions: async(options) => {
             options.AllowOverrideSettings = false;
             await Task.CompletedTask;
         },
             loggingSystemOptions: async(options) => {
             options.FileFactory = (stream) => new TextAndXmlLogFile(stream);
             options.CheckServiceState = true;
             options.LogOnUpdate = true;
             options.UseLongName = true;
             await Task.CompletedTask;
         }
             )
         .AddAppWorker <Program>();
         config.UnhandledError += Config_UnhandledError;
     }
                ).Build().RunAsync());
 }
Example #8
0
 public void Execute()
 {
     HostRunner.Start(Host);
 }
Example #9
0
 static void Main() => HostRunner.Run <AppHost>();