예제 #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create a trace listener for Web forms.
            WebPageTraceListener gbTraceListener = new WebPageTraceListener();

            // Add the event log trace listener to the collection.
            System.Diagnostics.Trace.Listeners.Add(gbTraceListener);

            if (!Orleans.GrainClient.IsInitialized)
            {
                bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("global.asax");
                }
                else
                {
                    OrleansClientConfig.TryStart("global.asax", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"));
                }

                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }
        }
        public AccessControlController()
        {
            try
            {
                if (!Orleans.GrainClient.IsInitialized)
                {
                    bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                    if (!dockerized)
                    {
                        OrleansClientConfig.TryStart("AccessControlController");
                    }
                    else
                    {
                        string hostname = System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"); //ConfigurationManager.AppSettings["dnsHostEntry"];
                        OrleansClientConfig.TryStart("AccessControlController", hostname);
                    }

                    Trace.TraceInformation("Orleans grain client initialized {0} is access control controller", Orleans.GrainClient.IsInitialized);
                    Task task = ServiceIdentityConfig.Configure();
                    Task.WhenAll(task);
                }


                bool started = OrleansClientConfig.TryStart("AccessControlController");
                Console.WriteLine("Orleans client started {0} on Web gateway.", started);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Orleans client on Web gateway failed with error {0}", ex.Message);
                Console.WriteLine(ex.StackTrace);
                Trace.TraceError("Orleans client error starting on Web gateway {0}", ex.Message);
            }
        }
        public ManageController()
        {
            bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);

            if (!dockerized)
            {
                string codesString = ConfigurationManager.AppSettings["managementCodes"];
                codes = codesString.Split(new char[] { ' ' });
            }
            else
            {
                string cstring = System.Environment.GetEnvironmentVariable("MGMT_API_SECURITY_CODE");
                codes = cstring.Split(new char[] { ' ' });
            }


            if (!Orleans.GrainClient.IsInitialized)
            {
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("ManageController");
                }
                else
                {
                    OrleansClientConfig.TryStart("ManageController", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"));
                }

                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }
        }
예제 #4
0
        public ConnectController()
        {
            if (!Orleans.GrainClient.IsInitialized)
            {
                bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("ConnectController");
                }
                else
                {
                    OrleansClientConfig.TryStart("ConnectController", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"));
                }

                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }

            try
            {
                config = Piraeus.Configuration.PiraeusConfigManager.Settings;
                source = new CancellationTokenSource();

                Trace.TraceInformation("Orleans grain client initialized {0} is connect controller", Orleans.GrainClient.IsInitialized);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
            }
        }
예제 #5
0
        static void InitOrleansClient()
        {
            int max   = 8;
            int index = 0;

            while (index < max)
            {
                Console.WriteLine("Initializing Orleans client...");
                index++;

                try
                {
                    if (!Orleans.GrainClient.IsInitialized)
                    {
                        bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                        if (!dockerized)
                        {
                            Console.WriteLine("Identified as localhost deployment");
                            if (OrleansClientConfig.TryStart("TCPGateway"))
                            {
                                return;
                            }
                            else
                            {
                                Console.WriteLine("Waiting 30 secs before retry {0} or {1}", index, max);
                            }
                        }
                        else
                        {
                            Console.WriteLine("Identified as docker deployment.");
                            if (OrleansClientConfig.TryStart("TCPGateway", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME")))
                            {
                                return;
                            }
                            else
                            {
                                Console.WriteLine("Waiting 30 secs before retry {0} or {1}", index, max);
                            }
                        }

                        Task task = ServiceIdentityConfig.Configure();
                        Task.WhenAll(task);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Orleans client failed loudly");
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("Waiting 30 secs before retry {0} or {1}", index, max);
                }

                Thread.Sleep(30000);
            }
        }
        protected void Application_Start()
        {
            // Catch unobserved exceptions from threads before they cause IIS to crash:
            TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs excArgs) =>
            {
                TraceSource trace = new TraceSource("UnhandledExceptionTrace");
                trace.TraceData(TraceEventType.Error, 1, excArgs.Exception);
                excArgs.SetObserved();
            };

            AppDomain.CurrentDomain.UnhandledException += (sender, args) => {
                Trace.TraceWarning("Web Gateway Unhandled exception");
                Trace.TraceWarning("Is Terminating {0}", args.IsTerminating);
                Exception ex = (Exception)args.ExceptionObject;
                Trace.TraceError(ex.Message);
                Trace.TraceError(ex.StackTrace);
            };



            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create a trace listener for Web forms.
            WebPageTraceListener gbTraceListener = new WebPageTraceListener();

            // Add the event log trace listener to the collection.
            System.Diagnostics.Trace.Listeners.Add(gbTraceListener);

            if (!Orleans.GrainClient.IsInitialized)
            {
                bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("global.asax");
                }
                else
                {
                    OrleansClientConfig.TryStart("global.asax", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"));
                }

                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }
        }
        public ServiceController()
        {
            if (!Orleans.GrainClient.IsInitialized)
            {
                bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("ServiceController");
                }
                else
                {
                    OrleansClientConfig.TryStart("ServiceController", System.Environment.GetEnvironmentVariable("GATEWAY_ORLEANS_SILO_DNS_HOSTNAME"));
                }

                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }
        }
        public AccessControlController()
        {
            if (!Orleans.GrainClient.IsInitialized)
            {
                bool dockerized = Convert.ToBoolean(ConfigurationManager.AppSettings["dockerize"]);
                if (!dockerized)
                {
                    OrleansClientConfig.TryStart("AccessControlController");
                }
                else
                {
                    string hostname = ConfigurationManager.AppSettings["dnsHostEntry"];
                    OrleansClientConfig.TryStart("AccessControlController", hostname);
                }

                Trace.TraceInformation("Orleans grain client initialized {0} is access control controller", Orleans.GrainClient.IsInitialized);
                Task task = ServiceIdentityConfig.Configure();
                Task.WhenAll(task);
            }


            bool started = OrleansClientConfig.TryStart("AccessControlController");
        }