Ejemplo n.º 1
0
        // handle close events
        private static bool Handler(CtrlType sig)
        {
            Console.WriteLine("Shutting down");

            // do some work on close
            string closeHash = SettingsHash.GetHash();

            SettingManager.Instance.Settings.CloseHash = closeHash;
            SettingManager.Instance.Save();
            if (!Cmd.RestartAdmin)
            {
                Thread.Sleep(200);
                Console.WriteLine("Cleanup complete");
                Thread.Sleep(150);
            }
            //shutdown right away
            Environment.Exit(-1);
            return(true);
        }
Ejemplo n.º 2
0
        private void Run(string[] args)
        {
            try
            {
                RestApiServer restApi = new RestApiServer();

                // register objects who would want to init system
                InitSystemManager.Instance.AddInitializer(restApi);


                if (shouldInit(args))
                {
                    // init whatever necessary
                    InitSystemManager.Instance.InitSystem();
                }
                else
                {
                    // check if we do not have to reinit system (reboot necessary)
                    string openHash  = SettingsHash.GetHash();
                    string closeHash = SettingManager.Instance.Settings.CloseHash;
                    if (!openHash.Equals(closeHash))
                    {
                        Cmd.RestartProcess(true);
                    }
                }

                restApi.Start();

                StateManager.Instance.LoadStateFromFile(SettingManager.Instance.Settings.CurrentProject);
                ArtnetIn.Instance.Start();
                new AutoSave().RunIfEnabled();
            }
            catch (Exception e) {
                HandleFatalException(e);
            }
        }