Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ConsoleWindow.EnableQuickEditMode(false);
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            var options = CommandLineUtil.ParseOptions <CommandLineOptions>(args);

            FileRecordCacheManager.Ins.Init(!options.DisableCache);

            StringTemplateManager.Ins.Init(!options.DisableCache);
            if (!string.IsNullOrEmpty(options.TemplateSearchPath))
            {
                StringTemplateManager.Ins.AddTemplateSearchPath(options.TemplateSearchPath);
            }
            StringTemplateManager.Ins.AddTemplateSearchPath(FileUtil.GetPathRelateApplicationDirectory("Templates"));

            Luban.Common.Utils.LogUtil.InitSimpleNLogConfigure(NLog.LogLevel.FromString(options.LogLevel));

            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            TimeZoneUtil.InitDefaultTimeZone(options.L10nDefaultTimeZone);

            GenServer.Ins.Start(false, options.Port, ProtocolStub.Factories);

            GenServer.Ins.RegisterJob("cfg", new Luban.Job.Cfg.JobController());
            GenServer.Ins.RegisterJob("proto", new Luban.Job.Proto.JobController());
            GenServer.Ins.RegisterJob("db", new Luban.Job.Db.JobController());

            int processorCount = System.Environment.ProcessorCount;

            ThreadPool.SetMinThreads(Math.Max(4, processorCount), 5);
            ThreadPool.SetMaxThreads(Math.Max(16, processorCount * 4), 10);

            Console.WriteLine("== running ==");
        }