Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIANXSVC-1186: Terminate application after writing metadata #20

Conversation

nachtjasmin
Copy link
Collaborator

@nachtjasmin nachtjasmin commented Jan 29, 2024

Closes SIANXSVC-1186

Proof of concept

In order to test that the changes work, the following code was used:

using Anexia.E5E.Extensions;
using Anexia.E5E.Functions;

var host = Host.CreateDefaultBuilder(args)
	.UseAnexiaE5E(_ => {}) // ignore the setup this time
	.UseConsoleLifetime()
	.Build();

await host.StartAsync();

await Task.Delay(10000); // imitate a long startup task

await host.WaitForShutdownAsync();

If I run this code with dotnet run metadata, the application prints the metadata and terminates immediately.

Caveats

Unfortunately, Environment.Exit would also end the test processes, therefore it had to be abstracted a bit.

@nachtjasmin nachtjasmin self-assigned this Jan 29, 2024
@nachtjasmin nachtjasmin force-pushed the chore/SIANXSVC-1186-update-documentation-for-dotnet-e5e-for-service-initialization branch from 3b177dc to 94eeafd Compare January 29, 2024 11:10
@nachtjasmin nachtjasmin added the documentation Improvements or additions to documentation label Jan 29, 2024
Copy link
Member

@PatrickTaibel PatrickTaibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work with the current metadata fetching implementation in e5e. Calling the metadata command outputs the expected JSON in time but the binary keeps running until the initialization is done.
e5e only starts to interpret the stdout after the binary exited with status code 0 to ensure that the metadata was generated successfully.
Therefore, the current way would not work in the following conditions:

  • long running initialization code
  • exceptions occurring (e.g. due to missing network connections)

@nachtjasmin nachtjasmin force-pushed the chore/SIANXSVC-1186-update-documentation-for-dotnet-e5e-for-service-initialization branch from d289e65 to 70e6efa Compare January 31, 2024 10:11
@nachtjasmin nachtjasmin changed the title SIANXSVC-1186: Update documentation for dotnet-e5e for service initialization SIANXSVC-1186: Terminate application after writing metadata Jan 31, 2024
@nachtjasmin nachtjasmin added the bug Something isn't working label Jan 31, 2024
@nachtjasmin nachtjasmin force-pushed the chore/SIANXSVC-1186-update-documentation-for-dotnet-e5e-for-service-initialization branch from 70e6efa to bde5e30 Compare January 31, 2024 10:13
Copy link
Member

@PatrickTaibel PatrickTaibel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata fetching now works as expected.

FYI this PR is not based on the current main, so the response result is not fixed yet. I'm missing permissions on this repo else I would have pushed my local rebase.

@nachtjasmin nachtjasmin force-pushed the chore/SIANXSVC-1186-update-documentation-for-dotnet-e5e-for-service-initialization branch from bde5e30 to 65a898f Compare February 1, 2024 15:38
@beachmachine beachmachine merged commit 25b1009 into main Feb 2, 2024
2 checks passed
@beachmachine beachmachine deleted the chore/SIANXSVC-1186-update-documentation-for-dotnet-e5e-for-service-initialization branch February 2, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants