private static JobManager CreateJobWorkersManager() { var start = DateTime.Parse("2015-06-23 15:10:00"); var expire = start.AddYears(2); var interval = start.FromMonths(1); IJob timedJob = new TimedJob(interval, TimeSpan.MaxValue, start, expire), insertJob = new InsertJob(TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(50)), updateJob = new UpdateJob(TimeSpan.FromSeconds(20), TimeSpan.FromSeconds(50)); var jobs = new[] { insertJob, updateJob, timedJob }; //new WebFarmJobCoordinator(new ) var manager = new JobManager(jobs, s => FileHelper.WriteFile("FilePath".Config(string.Empty), s)); manager.Fail(FileHelper.WriteException); manager.RestartSchedulerOnFailure = true; return(manager); }
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(); }
public void TestCancellation() { _jobCount = 0; AsyncProcessor processor = new AsyncProcessor(); using ( processor ) { TimedJob job = new TimedJob(); processor.QueueJobAt(DateTime.Now.AddSeconds(4), job); processor.QueueJobAt(DateTime.Now.AddSeconds(4.01), job); processor.CancelTimedJobs(job); processor.QueueEndOfWork(); processor.WaitUntilFinished(); if (_jobCount != -2) { throw new Exception("TestCancellation() failed. _jobCount = " + _jobCount); } } }
/// <summary> /// Initializes a new instance of the <see cref="TimedJobObserverContext"/> class. /// </summary> /// <param name="job">The job to execute.</param> public TimedJobObserverContext(TimedJob job) { Job = job; }