Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Parser            parser     = new CommandLine.Parser();
            bladeDirectorArgs parsedArgs = new bladeDirectorArgs();

            if (parser.ParseArgumentsStrict(args, parsedArgs, () => { Console.Write(HelpText.AutoBuild(parsedArgs).ToString()); }))
            {
                _Main(parsedArgs);
            }
        }
Ejemplo n.º 2
0
        public static void _Main(bladeDirectorArgs parsedArgs)
        {
            AppDomain.CurrentDomain.FirstChanceException += (sender, args) =>
            {
                try
                {
                    if (services.hostStateManager != null)
                    {
                        // We don't care about this kind of exception. It happens very frequently during normal use of the WMI
                        // executor.
                        if (!(args.Exception is COMException) &&
                            !(args.Exception is AggregateException && ((AggregateException)args.Exception).InnerExceptions.All(x => x is COMException)))
                        {
                            services.hostStateManager.addLogEvent("First-chance exception: " + args.Exception.ToString());
                        }
                    }

                    string dumpDir = Properties.Settings.Default.internalErrorDumpPath.Trim();
                    if (dumpDir != "")
                    {
                        // If this is a 'System.ServiceModel.FaultException', then it is destined to get to the caller via WCF. This is pretty bad, so we dump on these
                        // to aid debugging.
                        // We just use text matching here since perf shouldn't be critical (not many exceptions should happen).
                        if (args.Exception.GetType().ToString().StartsWith("System.ServiceModel.FaultException"))
                        {
                            miniDumpUtils.dumpSelf(Path.Combine(dumpDir, "FaultException_" + Guid.NewGuid().ToString() + ".dmp"));
                        }
                        // Lock violations are a pain to debug, even with all our debug output, so also drop a dump for those.
                        else if (args.Exception is ApplicationException || args.Exception is bladeLockExeception)
                        {
                            miniDumpUtils.dumpSelf(Path.Combine(dumpDir, "lockViolation_" + Guid.NewGuid().ToString() + ".dmp"));
                        }
                    }
                }
                catch (Exception)
                {
                    // ...
                }
            };

            if (!parsedArgs.baseURL.EndsWith("/"))
            {
                parsedArgs.baseURL = parsedArgs.baseURL + "/";
            }

            Uri baseServiceURL  = new Uri(new Uri(parsedArgs.baseURL), "bladeDirector");
            Uri debugServiceURL = new Uri(new Uri(parsedArgs.baseURL), "bladeDirectorDebug");
            Uri webServiceURL   = new Uri(new Uri(parsedArgs.webURL), "");

            using (WebServiceHost WebSvc = new WebServiceHost(typeof(webServices), baseServiceURL))
            {
                ServiceEndpoint ep = WebSvc.AddServiceEndpoint(typeof(IWebServices), new WebHttpBinding(), webServiceURL);
                ep.Behaviors.Add(new leakCheckerBehavior());

                if (!parsedArgs.disableWebPort)
                {
                    WebSvc.Open();
                }

                using (ServiceHost baseSvc = new ServiceHost(typeof(services), baseServiceURL))
                {
                    configureService(baseSvc, typeof(IServices));
                    baseSvc.Open();

                    using (ServiceHost debugSvc = new ServiceHost(typeof(debugServices), debugServiceURL))
                    {
                        configureService(debugSvc, typeof(IDebugServices));
                        debugSvc.Open();

                        if (!parsedArgs.disableWebPort)
                        {
                            using (bladeDirectorDebugServices conn = new bladeDirectorDebugServices(debugServiceURL.ToString(), baseServiceURL.ToString()))
                            {
                                conn.svc.setWebSvcURL(webServiceURL.ToString());
                            }
                        }

                        int[] bladeIDs = getBladeIDsFromString(parsedArgs.bladeList);
                        if (bladeIDs.Length > 0)
                        {
                            using (bladeDirectorDebugServices conn = new bladeDirectorDebugServices(debugServiceURL.ToString(), baseServiceURL.ToString()))
                            {
                                foreach (int id in bladeIDs)
                                {
                                    string bladeName = xdlClusterNaming.makeBladeFriendlyName(id);
                                    string bladeIP   = xdlClusterNaming.makeBladeIP(id);
                                    string iloIP     = xdlClusterNaming.makeBladeILOIP(id);
                                    string iSCSIIP   = xdlClusterNaming.makeBladeISCSIIP(id);
                                    ushort debugPort = xdlClusterNaming.makeBladeKernelDebugPort(id);
                                    string debugKey  = "the.default.key.here";
//                                    Console.WriteLine("Creating node {0}: IP {1}, ilo {2}, iSCSI IP {3}, debug port {4}, debug key {5}", id, bladeIP, iloIP, iSCSIIP, debugPort, debugKey);
                                    conn.svc.addNode(bladeIP, iSCSIIP, iloIP, debugPort, debugKey, bladeName);
                                }
                            }
                        }

                        if (parsedArgs.stopEvent != null)
                        {
                            parsedArgs.stopEvent.WaitOne();
                        }
                        else
                        {
                            Console.WriteLine("BladeDirector ready.");
                            Console.WriteLine("Listening at main endpoint:  " + baseServiceURL.ToString());
                            if (!parsedArgs.disableWebPort)
                            {
                                Console.WriteLine("Listening at web endpoint:   " + webServiceURL.ToString());
                            }
                            Console.WriteLine("Listening at debug endpoint: " + debugServiceURL.ToString());
                            Console.WriteLine("Hit [enter] to exit.");
                            Console.ReadLine();
                        }
                    }
                }
            }
        }