private static void Talk_OnTalk(Dictionary <string, string> v) { int pid, port; if (v["type"] == "AttachMemcached") { pid = Helper.ConvertTo <int>(v["mpid"]); port = Helper.ConvertTo <int>(v["mport"]); if (pid > 0 && port > 0) { Log.Warning("Attaching the memcached for pid {0}", pid); DataCacheInstance = Memcached.AttachExist("GeneralCache", (ushort)port, pid); } } }
static void Main(string[] args) { int mpid; ushort mport; Log.Init("backend"); Log.EnableLogType(LogType.Critical); Log.EnableLogType(LogType.Verbose); Log.EnableLogType(LogType.Info); Log.EnableLogType(LogType.Error); Log.EnableLogType(LogType.Warning); if (!Config.Get().IsOK) { Log.Critical("Some of required config settings missing."); return; } Log.DisableAll(); Log.EnableLogType((LogType)Config.Get().LogLevel); Log.Info("Booting up memcached instance"); mpid = TryGetOpt <int>("-mpid", args, 0); mport = TryGetOpt <ushort>("-mport", args, 0); if (mpid > 0 && mport > 0) { Log.Warning("Attach requested at pid: {0} and port {1}", mpid, mport); DataCacheInstance = Memcached.AttachExist("GeneralCache", mport, mpid); } else { DataCacheInstance = Memcached.Create("GeneralCache", 512, 11211); } if (Program.DataCacheInstance == null) { Log.Critical("Memcached could not started"); } else { Log.Info("Memcached ok"); } Init(); Console.CancelKeyPress += Console_CancelKeyPress; while (running) { Thread.Sleep(10); } Uninit(); Console.WriteLine("All resources released. press any key to exit"); Log._Finalize(); Console.ReadKey(); Environment.Exit(0); }