示例#1
0
        static void Uninit()
        {
            Log.Warning("Shutting down backend");

            Helper.KillProcess("sbmon");

            Talk.Stop();

            LogService.Stop();

            Edi.KillEdi();

            RequestBridge.Shutdown();

            RequestQueue.Shutdown();

            RequestDispatcher.Shutdown();

            DataCacheInstance.Instance.Shutdown();
        }
示例#2
0
        static void Main(string[] args)
        {
            bool enableWatchdog;

            Log.Init("sbmon");


            Log.EnableAll();
            int backendPid, memcachedPid;

            var opts = Helper.ParseOptions(string.Join(" ", args));

            talk = new InternalTalk(false);

            backendPid     = GetVal <int>(opts, "-backend", 0);
            memcachedPid   = GetVal <int>(opts, "-memcached", 0);
            MEMCACHED_PORT = GetVal <ushort>(opts, "-mport", 0);
            enableWatchdog = GetVal <bool>(opts, "-watchdog", true);

            if (backendPid == 0 && memcachedPid == 0)
            {
                Log.Critical("There are no pids supplied to monitor");
                return;
            }

            if (!InstanceCheck())
            {
                return;
            }

            if (enableWatchdog)
            {
                watchdog = new Watchdog();
                watchdog.Start();
            }
            else
            {
                Log.Warning("Watchdog disabled.");
            }

            if (backendPid > 0)
            {
                new HealthMonitor(backendPid, HealthMonitor.ProcessType.BackendProcess
                                  , RecoverPolicy.RecoverBackendAndPassExistedMemcachedInstance).Start();
            }

            if (memcachedPid > 0)
            {
                new HealthMonitor(memcachedPid, HealthMonitor.ProcessType.MemcachedProcess,
                                  RecoverPolicy.RecoverMemcachedAndPassNewMemcachedInstance).Start();
            }

            Console.CancelKeyPress += Console_CancelKeyPress;

            while (running)
            {
                Thread.Sleep(10);
            }

            if (enableWatchdog)
            {
                watchdog.Dispose();
            }

            talk.Stop();

            mutant.Dispose();

            Log._Finalize();
        }