private void Init(SimpleLoopTask loopTask) { var processInfos = GetProcessInfos("SimpleTrace.ini"); foreach (var processInfo in processInfos) { //var jaegerInfo = SimpleProcessInfo.Create("jaeger-all-in-one", "jaeger-all-in-one.exe", "--collector.zipkin.http-port=9411"); var process = SimpleProcess.GetOrCreate(processInfo); var processRunner = new SimpleProcessRunner(process); LogInfo(string.Format("Init ProcessRunner: [{0}]", processInfo.ProcessName)); Runners.Add(processRunner); } loopTask.LoopSpan = TimeSpan.FromSeconds(15); loopTask.LoopAction = () => { LogInfo("looping check trace service at " + DateHelper.Instance.GetDateNow().ToString("s")); foreach (var runner in Runners) { runner.TryStart(); } }; loopTask.AfterExitLoopAction = () => { LogInfo("stopping check trace service at " + DateHelper.Instance.GetDateNow().ToString("s")); foreach (var runner in Runners) { runner.TryStop(); } }; }
public BarService() { InitializeComponent(); _logHelper.Prefix = "[SimpleLog][BarService] "; LoopTask = new SimpleLoopTask(); Init(LoopTask); }
public SimpleTraceService() { InitializeComponent(); Runners = new List <SimpleProcessRunner>(); LoopTask = new SimpleLoopTask(); Init(LoopTask); }
public MockLoopTaskService() { InitializeComponent(); this.ServiceName = nameof(MockLoopTaskService); LoopTask = new SimpleLoopTask(); Init(LoopTask); }
public void Stop() { if (LoopTask == null) { Log.LogInfo("LoopTask already stopped!!!"); return; } LoopTask.Stop(); LoopTask.Dispose(); LoopTask = null; }
private void Init(SimpleLoopTask loopTask) { loopTask.LoopSpan = TimeSpan.FromSeconds(3); loopTask.LoopAction = () => { LoopTask.Log.LogInfo(string.Format("demo long running task is running at {0} in thread {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), Thread.CurrentThread.ManagedThreadId)); }; loopTask.AfterExitLoopAction = () => { LoopTask.Log.LogInfo(string.Format(">>> demo long running task is stopping at {0} in thread {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), Thread.CurrentThread.ManagedThreadId)); }; }
private void Init(SimpleLoopTask loopTask, SimpleProcessRunner runner) { loopTask.LoopSpan = TimeSpan.FromSeconds(3); loopTask.LoopAction = () => { runner.TryStart(); }; loopTask.AfterExitLoopAction = () => { runner.TryStop(); }; }
private void Init() { LoopTask = new SimpleLoopTask(); LoopTask.LoopSpan = TimeSpan.FromSeconds(3); LoopTask.LoopAction = () => { LogInfo(string.Format(">>> demo long running task is running at {0:yyyy-MM-dd HH:mm:ss:fff} in thread {1}", DateTime.Now, Thread.CurrentThread.ManagedThreadId)); }; LoopTask.AfterExitLoopAction = () => { LogInfo(string.Format(">>> demo long running task is stopping at {0:yyyy-MM-dd HH:mm:ss:fff} in thread {1}", DateTime.Now, Thread.CurrentThread.ManagedThreadId)); }; }
public void Init(TimeSpan?loopSpan, CommandQueueTask commandQueueTask, CommandQueue commandQueue, IEnumerable <ICommandLogistic> commandLogistics, IEnumerable <IClientSpanProcess> clientSpanProcesses, Func <DateTime> getNow) { if (LoopTask != null) { LogInfo("LoopTask already started!!!"); return; } CommandQueueTask = commandQueueTask ?? throw new ArgumentNullException(nameof(commandQueueTask)); CommandQueue = commandQueue ?? throw new ArgumentNullException(nameof(commandQueue)); CommandLogistics = commandLogistics == null ? throw new ArgumentNullException(nameof(commandQueue)) : commandLogistics.ToList(); ClientSpanProcesses = clientSpanProcesses == null ? throw new ArgumentNullException(nameof(clientSpanProcesses)) : clientSpanProcesses.ToList(); if (getNow == null) { throw new ArgumentNullException(nameof(getNow)); } LoopTask = new SimpleLoopTask(); if (loopSpan != null) { LoopTask.LoopSpan = loopSpan.Value; } LogInfo(string.Format(">>> LoopSpanSeconds: {0}", LoopTask.LoopSpan.TotalSeconds)); LoopTask.LoopTask = () => { LogInfo(string.Format(">>> looping at {0:yyyy-MM-dd HH:mm:ss} in thread {1}", DateTime.Now, Thread.CurrentThread.ManagedThreadId)); var now = getNow(); return(commandQueueTask.ProcessQueue(commandQueue, CommandLogistics, ClientSpanProcesses, now)); }; LoopTask.AfterExitLoopTask = () => { LogInfo(string.Format(">>> stopping at {0:yyyy-MM-dd HH:mm:ss} in thread {1}", DateTime.Now, Thread.CurrentThread.ManagedThreadId)); return(Task.FromResult(0)); }; }
public DaemonService() { InitializeComponent(); //var clientProcess = SimpleProcess.GetOrCreate(new SimpleProcessInfo() //{ // ProcessName = "FooClient", // ExePath = "FooClient.exe", // ExeArgs = null //}); var jaegerProcess = SimpleProcess.GetOrCreate(new SimpleProcessInfo() { ProcessName = "jaeger-all-in-one", ExePath = "jaeger-all-in-one.exe", ExeArgs = "--collector.zipkin.http-port=9411" }); var runner = new SimpleProcessRunner(jaegerProcess); LoopTask = new SimpleLoopTask(); Init(LoopTask, runner); }