Skip to content

Conversation

@ramonsmits
Copy link
Member

@ramonsmits ramonsmits commented Jan 15, 2024

A PersisterInitializingLifetimeWrapper that is DI configured to use a specific console or windowsservice lifetime.

@ramonsmits ramonsmits self-assigned this Jan 15, 2024
@ramonsmits ramonsmits changed the title Custom lifetime manager to prevent Windows Service start timeout Custom lifetime manager to prevent Windows Service start timeout - Generic IHostLifetime wrapper Jan 16, 2024
@ramonsmits ramonsmits marked this pull request as ready for review January 16, 2024 08:30
…ze()` as part of `IHostLifetime.WaitForStartAsync(..)` so that the application will not timeout in the (Windows) Service Control Manager and kill the process.
hostBuilder.UseWindowsService();
hostBuilder.ConfigureServices(s =>
{
s.AddSingleton<WindowsServiceLifetime>();
Copy link
Member

Choose a reason for hiding this comment

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

do we need this, considering line 15?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, as that line only registers an interface implementation and not the implementation separately.

using ServiceControl.Persistence;


sealed class PersisterInitializingLifetimeWrapper : IHostLifetime
Copy link
Member

Choose a reason for hiding this comment

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

could we make this more generic i.e. independent of persisted? Could be called HostLifetimeWithInitializationPhase

Copy link
Member Author

Choose a reason for hiding this comment

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

It could but then it should also have a constructor that allows for a more generic initialization but I don't think that is needed.

@ramonsmits
Copy link
Member Author

ramonsmits commented Jan 16, 2024

@ramonsmits ramonsmits closed this Jan 16, 2024
@mauroservienti mauroservienti deleted the custom-lifetime branch March 28, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants