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
Set startup time with env NATS_STARTUP_DELAY #3743
Conversation
The startup delay when starting as a service under windows was set to 10 seconds. This value was fixed and hardcoded since before JetStream. On (some) Windows systems, this leads to service startup failures, as the store dir sorting may be hindered by an important load, or slowed down by increased accesses times, typically from security software influence. This commit allows overriding the startup delay using an environment variable NATS_STARTUP_DELAY. This variable is checked outside init() to allow reporting into the service log. Any value can be used (even lower than the initial 10s). Bare NATS start can be far faster than 10s. Ops may want to setup this env var to lower values in order to trigger an error on stricter constraints.
Travis build fails, but it cannot be caused by the change. The changes all happen in a windows-only file, and all tests are run under linux focal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me. Could you add a test? Perhaps check the time on startup it would take to accept a connection.
@ColinSullivan1 I don't know if it's actually a good idea
I think we could make Would that be OK for you ? |
It would be good to update the docs too. |
|
Update : I tried to write some tests for this, but either I fail to reach the Other option is to mock the server to test I'll give it another try if I have a better inspiration. This definitely makes me realize why no tests were written for this piece of code previously. |
Happy year 2023 everyone. Travis still fails for some unrelated reason (no code in the proposed changes can run in Travis test suite that runs on Linux) The tests I propose here use a crude but sufficient windows services mock, and target the delay env var by setting it at the beginning of the test in order to make the startup fail ( |
@Alberic-Hardis Thanks! We've run the test on windows (thanks @scottf). LGTM! |
Hello all, |
Will be part of 2.10. |
The startup delay when starting as a service under windows was set to 10 seconds.
This value was fixed and hardcoded since before JetStream. On (some) Windows systems, this leads to service startup failures, as the store dir sorting may be hindered by an important load, or slowed down by increased accesses times, typically from security software influence.
This commit allows overriding the startup delay using an environment variable NATS_STARTUP_DELAY. This variable is checked outside init() to allow reporting into the service log.
Any value can be used (even lower than the initial 10s). Bare NATS start can be far faster than 10s. Ops may want to setup this env var to lower values in order to trigger an error on stricter constraints.
Resolves #NNN
git pull --rebase origin main
)Resolves #3742
Changes proposed in this pull request:
/cc @nats-io/core
Note : I could not add tests for this change, setting the value of the env var to low delays shows the change appears to have the expected behavior.