Skip to content

Conversation

@mauroservienti
Copy link
Member

@mauroservienti mauroservienti commented Feb 18, 2025

This PR exposes a new setting (ServiceControl*/ShutdownTimeout) to define the process shutdown timeout for all instances. The default value of 5 seconds has been selected based on the most restrictive hosting platform, containers on Linux. Linux containers allow for a maximum of ten seconds, and five were chosen to be as conservative as possible. That is less of an issue because when running ServiceControl using containers, we always run with an external RavenDB server, and the ServiceControl shutdown process is lightweight.

On the other hand, when installing Windows as a service, either via SCMU or PowerShell, the installation process sets the shutdown timeout to 2 minutes. By default, Windows allows services to shut down for a maximum of 125 seconds. However, every service is given only 30 seconds unless it requests additional time. For that reason, this PR also includes a custom WindowsServiceWithRequestTimeout component that requests additional time as defined by the new ShutdownTimeout setting when the service control manager invokes the stop. Unfortunately, there is no way to request extra time when the operating system is shutting down; in that case, there is a high chance that the ServiceControl embedded database doesn't shut down cleanly.

The new WindowsServiceWithRequestTimeout is registered when installing ServiceControl on Windows as a service and either run regularly or in maintenance mode.

@andreasohlund
Copy link
Member

Should this PR also update SCMU to set it to a higher value on upgrade? (since there we know its running as a win service)

@mauroservienti
Copy link
Member Author

Sure thing, @andreasohlund. I'll continue working on it.

@mauroservienti mauroservienti changed the title Allow setting shutdown timeout for primary and audit instances Allow setting shutdown timeout for all instances Mar 5, 2025
@mauroservienti mauroservienti force-pushed the allow-setting-shutdown-timeout branch from 949a723 to 210121a Compare March 6, 2025 07:40
@mauroservienti mauroservienti force-pushed the allow-setting-shutdown-timeout branch from 210121a to da0f1fe Compare March 6, 2025 07:47
@mauroservienti mauroservienti enabled auto-merge (squash) March 6, 2025 07:47
@mauroservienti
Copy link
Member Author

Rebased from master because the solution file changed

@mauroservienti mauroservienti merged commit 546b249 into master Mar 6, 2025
32 checks passed
@mauroservienti mauroservienti deleted the allow-setting-shutdown-timeout branch March 6, 2025 08:01
@mauroservienti mauroservienti added this to the vNext milestone Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants