コード例 #1
0
ファイル: Program.cs プロジェクト: zxahu/shinken
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            const string genlogfilename = "ShinkenStartlog.txt";
            // Default (and const) values...
            const string logfileconffilename = "Shinken_Scheduler";

            DirectLog.WriteFileEntry(genlogfilename, "Shinken Scheduler log configuration step...", DirectLog.LogLevel.Info);

            // Set a log file if specified into the configuration file
            NameValueCollection appSettings = ConfigurationManager.AppSettings;
            string logconf_filename         = appSettings[logfileconffilename];

            if (logconf_filename != null)
            {
                // For a windows service, the current dir is %WINDIR%\SYSTEM32, so we have
                // to change all the .\ or the relative path with the application startup path
                string currentconf = Application.StartupPath + @"\" + logconf_filename;
                DirectLog.WriteFileEntry(genlogfilename, "Shinken Scheduler logging conf set to " + currentconf, DirectLog.LogLevel.Info);
                XmlConfigurator.Configure(new System.IO.FileInfo(currentconf));
            }
#if DEBUG
            ShinkenScheduler_Service ShinkenScheduler = new ShinkenScheduler_Service();
            ShinkenScheduler.DirectStart();
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new ShinkenScheduler_Service()
            };

            // Run the set of services
            DirectLog.WriteFileEntry(genlogfilename, "Shinken Scheduler starting...", DirectLog.LogLevel.Info);
            ServiceBase.Run(ServicesToRun);
#endif
        }
コード例 #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            // Default (and const) values...
            const string logfileconffilename = "Shinken_Scheduler";

            // Set a log file if specified into the configuration file
            NameValueCollection appSettings = ConfigurationManager.AppSettings;
            string logconf_filename = appSettings[logfileconffilename];
            if (logconf_filename != null)
            {
                // For a windows service, the current dir is %WINDIR%\SYSTEM32, so we have
                // to change all the .\ or the relative path with the application startup path
                string currentconf = Application.StartupPath + @"\" + logconf_filename;
                XmlConfigurator.Configure(new System.IO.FileInfo(currentconf));
            }
            #if DEBUG
            ShinkenScheduler_Service ShinkenScheduler = new ShinkenScheduler_Service();
            ShinkenScheduler.DirectStart();
            #else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new ShinkenScheduler_Service()
            };

            // Run the set of services
            ServiceBase.Run(ServicesToRun);
            #endif
        }