Beispiel #1
0
        private void OnTimedShutdown(Object source, ElapsedEventArgs e)
        {
            countdownTimeNow = Util.GetLongTickCount();

            if (countdownTimeNow >= countdownTimeEnd)
            {
                shutdownCounter.Stop();
                m_app.Shutdown();
                countdownTimeEnd = 0;
                return;
            }

            ulong countdownRemaining = countdownTimeEnd - countdownTimeNow;

            if (countdownRemaining % (60UL * 1000UL) < 1000UL) // Within a second of every minute from 0.
            {
                string message = GenerateShutdownMessage((int)(countdownRemaining / 1000UL));
                m_log.DebugFormat("[RADMIN] Shutdown: {0}", message);

                IDialogModule dialogModule = rebootedScene.RequestModuleInterface <IDialogModule>();
                if (dialogModule != null)
                {
                    dialogModule.SendGeneralAlert(message);
                }
            }
        }
Beispiel #2
0
        public object RegionShutdownHandler(IList args, IPEndPoint remoteClient)
        {
            m_admin.CheckSessionValid(new UUID((string)args[0]));

            try
            {
                Scene  rebootedScene;
                string message;

                UUID regionID = new UUID(Convert.ToString(args[1]));
                int  delay    = Convert.ToInt32(args[2]);

                if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
                {
                    throw new Exception("Region not found");
                }

                message = GenerateShutdownMessage(delay);

                m_log.DebugFormat("[RADMIN] Shutdown: {0}", message);

                IDialogModule dialogModule = rebootedScene.RequestModuleInterface <IDialogModule>();
                if (dialogModule != null)
                {
                    dialogModule.SendGeneralAlert(message);
                }

                ulong tcNow      = Util.GetLongTickCount();
                ulong endTime    = tcNow + (ulong)(delay * 1000);
                ulong nextReport = tcNow + (ulong)(60 * 1000);

                // Perform shutdown
                if (delay > 0)
                {
                    while (true)
                    {
                        System.Threading.Thread.Sleep(1000);

                        tcNow = Util.GetLongTickCount();
                        if (tcNow >= endTime)
                        {
                            break;
                        }

                        if (tcNow >= nextReport)
                        {
                            delay -= 60;

                            if (delay >= 0)
                            {
                                GenerateShutdownMessage(delay);
                                nextReport = tcNow + (ulong)(60 * 1000);
                            }
                        }
                    }
                }

                // Do this on a new thread so the actual shutdown call returns successfully.
                Task.Factory.StartNew(() =>
                {
                    m_app.Shutdown();
                });
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message);
                m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString());
                throw e;
            }

            m_log.Info("[RADMIN]: Shutdown Administrator Request complete");
            return(true);
        }