コード例 #1
0
        /// <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_Broker";

            DirectLog.WriteFileEntry(genlogfilename, "Shinken Broker 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 Broker logging conf set to " + currentconf, DirectLog.LogLevel.Info);
                XmlConfigurator.Configure(new System.IO.FileInfo(currentconf));
            }
#if DEBUG
            ShinkenBroker_Service ShinkenBroker = new ShinkenBroker_Service();
            ShinkenBroker.DirectStart();
#else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new ShinkenBroker_Service()
            };

            // Run the set of services
            DirectLog.WriteFileEntry(genlogfilename, "Shinken Broker 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_Broker";

            // 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
            ShinkenBroker_Service ShinkenBroker = new ShinkenBroker_Service();
            ShinkenBroker.DirectStart();
            #else
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new ShinkenBroker_Service()
            };

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