diff --git a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs index 16140a09..f3f70ebe 100644 --- a/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs +++ b/Oqtane.Server/Infrastructure/Jobs/HostedServiceBase.cs @@ -266,17 +266,27 @@ namespace Oqtane.Infrastructure jobs.UpdateJob(job); } } + } + catch + { + // error updating the job + } - if (_executingTask == null) - { - return; - } + // stop called without start + if (_executingTask == null) + { + return; + } + try + { + // force cancellation of the executing method _cancellationTokenSource.Cancel(); } finally { - await Task.WhenAny(_executingTask, Task.Delay(Timeout.Infinite, cancellationToken)); + // wait until the task completes or the stop token triggers + await Task.WhenAny(_executingTask, Task.Delay(Timeout.Infinite, cancellationToken)).ConfigureAwait(false); } } diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs index 34ca42d1..c3ec9217 100644 --- a/Oqtane.Server/Startup.cs +++ b/Oqtane.Server/Startup.cs @@ -58,6 +58,7 @@ namespace Oqtane services.AddLocalization(options => options.ResourcesPath = "Resources"); services.AddOptions>().Bind(Configuration.GetSection(SettingKeys.AvailableDatabasesSection)); + services.Configure(opts => opts.ShutdownTimeout = TimeSpan.FromSeconds(10)); // increase from default of 5 seconds services.AddServerSideBlazor() .AddCircuitOptions(options =>