예제 #1
0
파일: TheMain.cs 프로젝트: smc314/helix
        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
파일: TheMain.cs 프로젝트: smc314/helix
 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;
 }