-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/change-fce-media-types
- Loading branch information
Showing
5 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
".": "1.47.7" | ||
".": "1.47.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/Digdir.Domain.Dialogporten.WebApi/DelayedShutdownHostLifetime.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Runtime.InteropServices; | ||
|
||
namespace Digdir.Domain.Dialogporten.WebApi; | ||
|
||
public sealed class DelayedShutdownHostLifetime : IHostLifetime, IDisposable | ||
{ | ||
private readonly IHostApplicationLifetime _applicationLifetime; | ||
private readonly TimeSpan _delay; | ||
private IEnumerable<IDisposable>? _disposables; | ||
|
||
public DelayedShutdownHostLifetime(IHostApplicationLifetime applicationLifetime, TimeSpan delay) | ||
{ | ||
_applicationLifetime = applicationLifetime; | ||
_delay = delay; | ||
} | ||
|
||
public Task StopAsync(CancellationToken cancellationToken) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
|
||
public Task WaitForStartAsync(CancellationToken cancellationToken) | ||
{ | ||
_disposables = new IDisposable[] | ||
{ | ||
PosixSignalRegistration.Create(PosixSignal.SIGINT, HandleSignal), | ||
PosixSignalRegistration.Create(PosixSignal.SIGQUIT, HandleSignal), | ||
PosixSignalRegistration.Create(PosixSignal.SIGTERM, HandleSignal) | ||
}; | ||
return Task.CompletedTask; | ||
} | ||
|
||
private void HandleSignal(PosixSignalContext ctx) | ||
{ | ||
ctx.Cancel = true; | ||
Task.Delay(_delay).ContinueWith(t => _applicationLifetime.StopApplication()); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
foreach (var disposable in _disposables ?? Enumerable.Empty<IDisposable>()) | ||
{ | ||
disposable.Dispose(); | ||
} | ||
GC.SuppressFinalize(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.47.7 | ||
1.47.8 |