Ejemplo n.º 1
0
        public new static ContainerLocal Create(string accountName, string accountKey)
        {
            if (instance == null)
            {
                instance = new ContainerLocal(accountName, accountKey);
            }

            return(instance);
        }
Ejemplo n.º 2
0
        private static async Task RunAsync(string[] args)
        {
            try
            {
                if (dockerConfig.FeatureFlags.HasFlag(LogModuleFeatureFlags.EdgeHubHost))
                {
                    edgeHubClient = await ModuleClient.CreateFromEnvironmentAsync(TransportType.Mqtt);

                    await edgeHubClient.OpenAsync();

                    Console.WriteLine("Edge Hub client created");

                    local       = ContainerLocal.Create(dockerConfig.BlobStorageAccountName, dockerConfig.BlobStorageAccountKey);
                    edgeHubHost = new EdgeHubLogHost(edgeHubClient, local);
                    edgeHubHost.Init();
                    Console.WriteLine("Edge Hub Host Initialized");
                }
                else
                {
                    Console.WriteLine("-----> Edge Hub Host NOT configured <-----");
                }

                if (dockerConfig.FeatureFlags.HasFlag(LogModuleFeatureFlags.DirectMethodsHost))
                {
                    directMethodsClient = await ModuleClient.CreateFromEnvironmentAsync(TransportType.Mqtt);

                    await directMethodsClient.OpenAsync();

                    Console.WriteLine("Direct Methods client created");

                    remote            = ContainerRemote.Create(dockerConfig.BlobStorageAccountName, dockerConfig.BlobStorageAccountKey);
                    directMethodsHost = new DirectMethodsHost(directMethodsClient, remote);
                    directMethodsHost.Init();
                    Console.WriteLine("Direct Methods Host Initialized");
                }
                else
                {
                    Console.WriteLine("-----> Direct Methods Host NOT configured <-----");
                }

                if (dockerConfig.FeatureFlags.HasFlag(LogModuleFeatureFlags.WebHost))
                {
                    CreateWebHostBuilder(args).Build().Run();
                    Console.WriteLine("Web Host Initialized");
                }
                else
                {
                    Console.WriteLine("-----> Web Host NOT configured <-----");
                }

                Console.WriteLine("Started all services");
            }
            catch (Exception ex)
            {
                Console.WriteLine("---------- WARNING ----------");
                Console.WriteLine("-----> ERROR: CONFIG FAILED <-----");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.WriteLine("----------------------------");
                throw ex;
            }
        }