Пример #1
0
 public SubjectParser()
 {
     err    = null;
     patern = null;
     sr     = null;
     list   = new List <SubjectInstance>();
     UpdatePatern().GetAwaiter().GetResult();
     UpdateAutoreplace();
     Current = this;
 }
Пример #2
0
        public Task Initialize(string[] args)
        {
            var f = args?[0];

            if (string.IsNullOrEmpty(f))
            {
                Console.WriteLine("You must specify port");
                Environment.Exit(-1);
            }
            var port = -1;

            if (int.TryParse(f, out var portx))
            {
                port = portx;
            }
            return(ReactorStartup.From(args)
                   .ConfigureLogger(new LoggerConfiguration {
                WriteToConsole = true
            })
                   .Configure((with, core) =>
            {
                Core = core;
                core.DirectoryManager
                .GetFor <Dirs>(MaxRev.Servers.Utils.Filesystem.Dirs.WorkDir)
                .AddDir(Dirs.Addons, "addons");
                core.DirectoryManager
                .GetFor <Dirs>(MaxRev.Servers.Utils.Filesystem.Dirs.WorkDir)
                .AddDir(Dirs.Addons, Dirs.Subject_Parser, "subjects_parser");

                //var servers = LoadBalancer.GetServers(Core, "Schedule", 2, (serv, isMain) =>
                // {
                //     serv.SetApiControllers(typeof(APIUtilty.API));
                //     if (serv.Config.Main != null)
                //         serv.Config.Main.ServerTypeName = new KeyValuePair<string, string>("X-NS-Type", "Schedule");

                //     if (isMain)
                //     {
                //         serv.EventMaster.ServerStarting += OnServerStart;
                //         return serv;
                //     }

                //     return serv;
                // });
                with.Server("Schedule", out var server, port);
                server.SetApiControllers(typeof(API));
                //server.Features.AddFeature(new CustomHeaderHandler());
                server.CustomRequestPreProcessor = CustomHeaderHandler;
                server.EventMaster.ServerStarting += (s, e) =>
                                                     _subjectParser = new SubjectParser();
            }).RunAsync());
        }