Exemple #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 ==");
        }
        static void Main(string[] args)
        {
            ConsoleWindow.EnableQuickEditMode(false);
            Console.OutputEncoding = System.Text.Encoding.UTF8;
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

            var parseResult = ParseArgs(args);

            if (parseResult.Item1 != null)
            {
                PrintUsage((string)parseResult.Item1);
                Environment.Exit(1);
                return;
            }
            var options = parseResult.Item2;

            var profile = new ProfileTimer();

            profile.StartPhase("all");

            LogUtil.InitSimpleNLogConfigure(NLog.LogLevel.FromString(options.LogLevel));
            s_logger = NLog.LogManager.GetCurrentClassLogger();

            TimeZoneUtil.InitDefaultTimeZone("");

            int processorCount = System.Environment.ProcessorCount;

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

            if (string.IsNullOrEmpty(options.TemplateSearchPath))
            {
                options.TemplateSearchPath = FileUtil.GetPathRelateApplicationDirectory("Templates");
            }
            if (string.IsNullOrWhiteSpace(options.Host))
            {
                options.Host = "127.0.0.1";
                StartServer(options);
            }

            StartClient(options, profile);
        }