Inheritance: System.ServiceProcess.ServiceBase
Beispiel #1
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;
            if (config == null)
            {
                Logger.Error("Main(): cannot get configuration section");
                return;
            }

            var collectdWinService = new CollectdWinService();

            if (Array.Find(args, s => s.Equals(@"console")) != null)
            {
                Console.WriteLine("*** Starting CollectdWin in console mode***");
                // run as a console application for testing and debugging purpose
                collectdWinService.StartService();
                Console.WriteLine("*** Enter Ctrl-C to exit: ***");
                Console.ReadLine();
            }
            else
            {
                // run as a windows service
                ServiceBase[] servicesToRun = {collectdWinService};
                ServiceBase.Run(servicesToRun);
            }
            Logger.Error("CollectdWin: exiting ...");
        }
Beispiel #2
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;

            if (config == null)
            {
                Logger.Error("Main(): cannot get configuration section");
                return;
            }

            var collectdWinService = new CollectdWinService();

            if (Array.Find(args, s => s.Equals(@"console")) != null)
            {
                Console.WriteLine("*** Starting CollectdWin in console mode***");
                // run as a console application for testing and debugging purpose
                collectdWinService.StartService();
                Console.WriteLine("*** Enter Ctrl-C to exit: ***");
                Console.ReadLine();
            }
            else
            {
                // run as a windows service
                ServiceBase[] servicesToRun = { collectdWinService };
                ServiceBase.Run(servicesToRun);
            }
            Logger.Error("CollectdWin: exiting ...");
        }
Beispiel #3
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;
            if (config == null)
            {
                Logger.Error("Main(): cannot get configuration section");
                return;
            }

            var collectdWinService = new CollectdWinService();

            if (Array.Find(args, s => s.Equals(@"/console")) != null)
            {
                // run as a console application for testing and debugging purpose
                collectdWinService.StartService();
            }
            else
            {
                // run as a windows service
                ServiceBase[] servicesToRun = {collectdWinService};
                ServiceBase.Run(servicesToRun);
            }
        }
Beispiel #4
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            #if DEBUG
                System.Diagnostics.Debugger.Launch();
            #endif
            try {
                var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;
                if (config == null)
                {
                    Logger.Fatal("Main(): cannot get configuration section");
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal("Failed to parse configuration", ex);
                return;
            }

            var collectdWinService = new CollectdWinService();

            if (Array.Find(args, s => s.Equals(@"console")) != null)
            {
                Console.WriteLine("Starting CollectdWin...");
                // run as a console application for testing and debugging purpose
                collectdWinService.StartService();
                Console.WriteLine("Press Ctrl-C to exit.");
                Console.ReadLine();
            }
            else
            {
                // run as a windows service
                ServiceBase[] servicesToRun = {collectdWinService};
                ServiceBase.Run(servicesToRun);
            }
        }
Beispiel #5
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        public static void Main(string[] args)
        {
            #if DEBUG
            System.Diagnostics.Debugger.Launch();
            #endif
            try {
                var config = ConfigurationManager.GetSection("CollectdWinConfig") as CollectdWinConfig;
                if (config == null)
                {
                    Logger.Fatal("Main(): cannot get configuration section");
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal("Failed to parse configuration", ex);
                return;
            }

            var collectdWinService = new CollectdWinService();

            if (Array.Find(args, s => s.Equals(@"console")) != null)
            {
                Console.WriteLine("Starting CollectdWin...");
                // run as a console application for testing and debugging purpose
                collectdWinService.StartService();
                Console.WriteLine("Press Ctrl-C to exit.");
                Console.ReadLine();
            }
            else
            {
                // run as a windows service
                ServiceBase[] servicesToRun = { collectdWinService };
                ServiceBase.Run(servicesToRun);
            }
        }