Renamed Worker.Scriptable to ScriptContainer, added cancellation token, Added LoggerWrapper to circumnavigate CLR issues, improved logging, added logging to ScriptToolSet

This commit is contained in:
2025-08-31 14:59:41 +02:00
parent 0647f10ca1
commit 14a6acf50f
9 changed files with 167 additions and 52 deletions

View File

@@ -87,7 +87,7 @@ public class CallsController : ControllerBase
}
[HttpGet("Disable")]
public ActionResult<CallDisableResult> Disable(string workerName, string? callName)
public ActionResult<CallDisableResult> Disable(string workerName, string? callName, bool? requestStop = false)
{
_workerCollection.Workers.TryGetValue(workerName, out Worker? worker);
if (worker is null)
@@ -101,6 +101,10 @@ public class CallsController : ControllerBase
foreach (ICall call in worker.Calls)
{
call.Disable();
if (requestStop == true)
{
call.Stop();
}
}
_logger.LogInformation("Stopped calls in worker {name}.", [workerName]);
} else
@@ -114,6 +118,10 @@ public class CallsController : ControllerBase
}
_logger.LogInformation("Starting call {callName} in worker {workerName}.", [callName, workerName]);
call.Disable();
if (requestStop == true)
{
call.Stop();
}
}
return new CallDisableResult { Success = true };
}

View File

@@ -68,17 +68,17 @@ public class WorkerController : ControllerBase
}
_logger.LogInformation("triggering worker {name}.", [name]);
ManualTriggerCallbackInfos callbackInfos = new();
lock (worker.Scriptable)
lock (worker.ScriptContainer)
{
worker.IsExecuting = true;
worker.Scriptable.Update(callbackInfos);
worker.ScriptContainer.Update(callbackInfos);
worker.IsExecuting = false;
DateTime beforeExecution = DateTime.Now;
worker.IsExecuting = true;
try
{
worker.Scriptable.Update(callbackInfos);
worker.ScriptContainer.Update(callbackInfos);
}
finally
{