Skip to content

Commit

Permalink
Merge branch 'main' into feat/change-fce-media-types
Browse files Browse the repository at this point in the history
  • Loading branch information
oskogstad authored Feb 3, 2025
2 parents ae6c339 + d784890 commit 0d6e800
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.47.7"
".": "1.47.8"
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [1.47.8](https://github.com/Altinn/dialogporten/compare/v1.47.7...v1.47.8) (2025-02-03)


### Bug Fixes

* **web-api:** ensure graceful shutdown ([#1784](https://github.com/Altinn/dialogporten/issues/1784)) ([509aa33](https://github.com/Altinn/dialogporten/commit/509aa3371ecc7c87cc8f40232a4016783546a934))


### Miscellaneous Chores

* **deps:** update peter-evans/repository-dispatch action to v3 ([#1778](https://github.com/Altinn/dialogporten/issues/1778)) ([8be436e](https://github.com/Altinn/dialogporten/commit/8be436e39c0bb6b5d326027062faed3996eeb446))
* Remove unneeded name lookup ([#1781](https://github.com/Altinn/dialogporten/issues/1781)) ([3cbdc9d](https://github.com/Altinn/dialogporten/commit/3cbdc9d81b1844d3e5a365c9478840df2b3e015f))

## [1.47.7](https://github.com/Altinn/dialogporten/compare/v1.47.6...v1.47.7) (2025-01-31)


Expand Down
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);
}
}
5 changes: 5 additions & 0 deletions src/Digdir.Domain.Dialogporten.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ static void BuildAndRun(string[] args)
.ValidateFluently()
.ValidateOnStart();

builder.Services.AddSingleton<IHostLifetime>(sp => new DelayedShutdownHostLifetime(
sp.GetRequiredService<IHostApplicationLifetime>(),
TimeSpan.FromSeconds(10)
));

var thisAssembly = Assembly.GetExecutingAssembly();

builder.Services
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.47.7
1.47.8

0 comments on commit 0d6e800

Please sign in to comment.