Пример #1
0
        public void InternalExecute()
        {
            using (EnEx ee = new EnEx ("TheMain::InternalExecute()")) {
                Log.Info ("TheMain Starting execution");
                try {
                    m_shutdown = false;
                    m_is_shutdown_reconfig = false;

                    Log.Info("Creating thread list");
                    m_threads = new ThreadList();
                    m_our_threads = new List<KeyValuePair<Thread, Threadable>>();

                    // Start draining and writing logs
                    InitLogs();

                    InitStorageDB();

                    // Create and launch any IOAdapters that we have defined
                    // so that we can listen for incomming messages.  The scheduler
                    // is started here as well.
                    LaunchIOAdapters();

                    // Start up our message processing thread to handle passing
                    // messages to ActionClass implementors.
                    LaunchMsgProcScaler();

                    Log.Info("TheMain::Execute everything started.  Waiting for shutdown notice.");

                    int uptime = 0;
                    int oneMinute = 0;
                    // Wait for someone to tell us to stop
                    while(!m_shutdown){
                        System.Threading.Thread.Sleep(1000); // 1 second nap

                        // tracks the number of seconds (roughly)
                        // that we've been up.
                        uptime++;
                        oneMinute++;
                        if(oneMinute == 600){
                            // Dump interesting things to the log file every 10 minutes
                            DumpStateToLogs();
                            oneMinute = 0;
                        }
                    }

                } catch (Exception e){
                    Log.Panic ("Something broke: {0}", e.Message);
                }

                try {
                    Log.Info("Shutting down all threads");
                    DumpStateToLogs();

                    ShutdownThreads();

                    ShutdownLogger();
                    // logging goes to stdout at this point.

                    m_threads = null;

                    m_shutdown_done = true;

                } catch (Exception e){
                    Log.Panic("Something broke during shutdown: {0}", e.Message);
                }

            } // End EnEx using
        }
Пример #2
0
 public ThreadList GetThreadList()
 {
     if (m_threads == null) {
         Log.Warn ("Thread list is NULL, creating on the fly - this may not be what you want.");
         m_threads = new ThreadList ();
     }
     return m_threads;
 }