示例#1
0
        public static void Main(string[] args)
        {
            StartUpTime = DateTime.Now;
            L.InitLog();
            L.I("WoodenBench WebServer Starting....");
            L.I($"Startup Time {StartUpTime.ToString()}.");

            Version = new FileInfo(new string(Assembly.GetExecutingAssembly().CodeBase.Skip(8).ToArray())).LastWriteTime.ToString();
            L.I($"Version: {Version}");

            var v = XConfig.LoadAll();

            if (!(v.Item1 && v.Item2))
            {
                L.E("XConfig Load error... Quiting");
                return;
            }

            L.I("Starting Job Watcher");
            TimedJob.StartJobWatcher();
            TimedJob.AddToJobList("Get Config", XConfig.ServerConfig.GetConfig, 10, 0);
            TimedJob.AddToJobList("Session Checker", BaseController.CheckSessions, 10, 0);
            TimedJob.AddToJobList("Status Monitor", StatusMonitor.SendStatus, 10);

            DataBaseOperation.InitialiseClient();

            XConfig.ServerConfig.GetConfig();

            WeChatHelper.PrepareCodes();
            WeChatHelper.InitialiseEncryptor();

            L.I("Initialising Core Messaging Systems.....");
            WeChatMessageSystem.StartProcessThreads();
            WeChatMessageBackupService.StartBackupThread();
            MessagingSystem.StartProcessThread();

            var webHost = BuildWebHost(args, XConfig.Current.ApplicationInsightInstrumentationKey);

            L.I("Starting WebHost....");
            WebServerTask = webHost.RunAsync(ServerStopToken.Token);
            WebServerTask.Wait();
            L.E("WebServer Stoped! Cancellation Token = " + ServerStopToken.IsCancellationRequested);
            DatabaseSocketsClient.KillConnection();
        }
示例#2
0
        public static void Main(string[] args)
        {
            LW.SetLogLevel(LogLevel.Dbg);
            LW.InitLog();
            StartUpTime = DateTime.Now;
            LW.D("WoodenBench WebServer Starting....");
            LW.D($"\t Startup Time {StartUpTime.ToString()}.");
            Version = new FileInfo(new string(Assembly.GetExecutingAssembly().CodeBase.Skip(8).ToArray())).LastWriteTime.ToString();
            LW.D($"\t Version {Version}");

            var v = XConfig.LoadAll();

            if (!(v.Item1 && v.Item2))
            {
                return;
            }

            StatusMonitor.StartMonitorThread();
            WeChatHelper.ReNewWCCodes();

            DataBaseOperation.InitialiseClient();
            //DataBaseOperation.InitialiseClient(IPAddress.Loopback);

            WeChatHelper.InitialiseExcryptor();

            LW.D("Initialising Core Messaging Systems.....");
            WeChatMessageSystem.StartProcessThreads();
            WeChatMessageBackupService.StartBackupThread();
            MessagingSystem.StartProcessThread();

            var webHost = BuildWebHost(XConfig.Current.ApplicationInsightInstrumentationKey, args);

            LW.D("Starting WebHost....");

            WebServerTask = webHost.RunAsync(ServerStopToken.Token);
            WebServerTask.Wait();
            LW.E("WebServer Stoped! Cancellation Token = " + ServerStopToken.IsCancellationRequested);
        }