private static int Main(string[] args)
        {
            try
            {
                var options = new Options();

                var log = SetUpLogConfig();

                // If bad args were passed, will exit and print usage
                Parser.Default.ParseArgumentsStrict(args, options);

                var settings = ConfigurationParser.ParseSettings(log, options.ConfigFile);
                Settings.Default = settings;

                var installController = new InstallController(settings.ServiceName, log);
                if (options.Uninstall)
                {
                    installController.Uninstall();
                }
                else if (options.Install)
                {
                    installController.Install();
                }
                else if (options.Start)
                {
                    installController.StartService();
                }
                else if (options.Stop)
                {
                    installController.StopService();
                }
                else if (options.InstallOrStart)
                {
                    installController.InstallOrStart();
                }
                else
                {
                    Thread.CurrentThread.Name = "Main";

                    settings.CollectOnly = options.CollectOnly;

                    log.Debug("Loaded Settings:");
                    settings.ToLog(log);

                    if (Environment.UserInteractive)
                    {
                        Console.Out.WriteLine("Starting Interactive mode");
                        RunInteractive(settings);
                    }
                    else
                    {
                        ServiceBase[] services = {new SqlMonitorService(settings)};
                        ServiceBase.Run(services);
                    }
                }

                return 0;
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);

                if (Environment.UserInteractive)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine("Press any key to exit...");
                    Console.ReadKey();
                }

                return -1;
            }
        }
        private static int Main(string[] args)
        {
            try
            {
                var log = SetUpLogConfig();

                var options = Options.ParseArguments(args);

                var settings = ConfigurationParser.ParseSettings(log, options.ConfigFile);
                Settings.Default = settings;

                var installController = new InstallController(settings.ServiceName, settings.IsProcessElevated);
                if (options.Uninstall)
                {
                    installController.Uninstall();
                }
                else if (options.Install)
                {
                    installController.Install();
                    if (options.Start)
                        installController.StartService();
                }
                else if (options.Start)
                {
                    installController.StartService();
                }
                else if (options.Stop)
                {
                    installController.StopService();
                }
                else if (options.InstallOrStart)
                {
                    installController.InstallOrStart();
                }
                else
                {
                    Thread.CurrentThread.Name = "Main";
                    settings.TestMode = options.TestMode;
                    log.InfoFormat("New Relic Sql Server Plugin");
                    log.Info("Loaded Settings:");
                    settings.ToLog(log);

                    if (!settings.Endpoints.Any())
                    {
                        log.Error("No sql endpoints found please, update the configuration file to monitor one or more sql server instances.");
                    }

                    if (Environment.UserInteractive)
                    {
                        RunInteractive(settings);
                    }
                    else
                    {
                        ServiceBase[] services = {new SqlMonitorService(settings)};
                        ServiceBase.Run(services);
                    }
                }

                return 0;
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);

                if (Environment.UserInteractive)
                {
                    Console.Out.WriteLine();
                    Console.Out.WriteLine("Press any key to exit...");
                    Console.ReadKey();
                }

                return -1;
            }
        }