diff --git a/Shoko.Server/API/v3/Controllers/DebugController.cs b/Shoko.Server/API/v3/Controllers/DebugController.cs index 403a998c6..0bccef062 100644 --- a/Shoko.Server/API/v3/Controllers/DebugController.cs +++ b/Shoko.Server/API/v3/Controllers/DebugController.cs @@ -15,7 +15,7 @@ using Shoko.Server.Providers.AniDB.Interfaces; using Shoko.Server.Providers.AniDB.UDP.Exceptions; using Shoko.Server.Scheduling; -using Shoko.Server.Scheduling.Jobs; +using Shoko.Server.Scheduling.Jobs.Test; using Shoko.Server.Settings; #nullable enable @@ -50,7 +50,7 @@ public DebugController(ILogger logger, IUDPConnectionHandler ud /// /// /// - [HttpGet("ScheduleTestJobs/{count}")] + [HttpGet("ScheduleJobs/Delay/{count}")] public async Task ScheduleTestJobs(int count, [FromQuery]int seconds = 60) { var scheduler = await _schedulerFactory.GetScheduler(); @@ -66,6 +66,25 @@ await scheduler.StartJobNow(t => return Ok(); } + /// + /// Schedule {} jobs that just error + /// + /// + [HttpGet("ScheduleJobs/Error/{count}")] + public async Task ScheduleTestErrorJobs(int count) + { + var scheduler = await _schedulerFactory.GetScheduler(); + for (var i = 0; i < count; i++) + { + await scheduler.StartJobNow(t => + { + t.Offset = i; + }); + } + + return Ok(); + } + /// /// Call the AniDB UDP API using the /// diff --git a/Shoko.Server/Scheduling/Jobs/BaseJob.cs b/Shoko.Server/Scheduling/Jobs/BaseJob.cs index c2a6b87a6..20fb59886 100644 --- a/Shoko.Server/Scheduling/Jobs/BaseJob.cs +++ b/Shoko.Server/Scheduling/Jobs/BaseJob.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using System.Xml.Serialization; using JetBrains.Annotations; @@ -21,8 +20,8 @@ public async Task Execute(IJobExecutionContext context) } catch (Exception ex) { - _logger.LogError(ex, "Job threw an error on Execution: {Job} | Error -> {Ex}", context.JobDetail.Key, ex); - throw new JobExecutionException(msg: ex.Message, refireImmediately: false, cause: ex); + // _logger.LogError(ex, "Job threw an error on Execution: {Job} | Error -> {Ex}", context.JobDetail.Key, ex); + throw new JobExecutionException(msg: ex.Message, cause: ex); } } diff --git a/Shoko.Server/Scheduling/Jobs/TestDelayJob.cs b/Shoko.Server/Scheduling/Jobs/Test/TestDelayJob.cs similarity index 93% rename from Shoko.Server/Scheduling/Jobs/TestDelayJob.cs rename to Shoko.Server/Scheduling/Jobs/Test/TestDelayJob.cs index e632e6f46..3c3c1f41a 100644 --- a/Shoko.Server/Scheduling/Jobs/TestDelayJob.cs +++ b/Shoko.Server/Scheduling/Jobs/Test/TestDelayJob.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging; using Shoko.Server.Scheduling.Attributes; -namespace Shoko.Server.Scheduling.Jobs; +namespace Shoko.Server.Scheduling.Jobs.Test; [JobKeyGroup(JobKeyGroup.System)] public class TestDelayJob : BaseJob diff --git a/Shoko.Server/Scheduling/Jobs/Test/TestErrorJob.cs b/Shoko.Server/Scheduling/Jobs/Test/TestErrorJob.cs new file mode 100644 index 000000000..5e4882954 --- /dev/null +++ b/Shoko.Server/Scheduling/Jobs/Test/TestErrorJob.cs @@ -0,0 +1,20 @@ +using System; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Shoko.Server.Scheduling.Attributes; + +namespace Shoko.Server.Scheduling.Jobs.Test; + +[JobKeyGroup(JobKeyGroup.System)] +public class TestErrorJob : BaseJob +{ + public int Offset { get; set; } + public override string TypeName => "Test Error"; + public override string Title => "Throwing an Error"; + + public override Task Process() + { + _logger.LogInformation("Processing {Job}", nameof(TestErrorJob)); + throw new Exception("TEST TEST TEST ERROR!!!"); + } +}