-
Notifications
You must be signed in to change notification settings - Fork 158
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
Fix run as service detection #4002
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atoulme
reviewed
Dec 4, 2023
// If environment variable NO_WINDOWS_SERVICE is set with any value other | ||
// than 0, use interactive mode instead of running as a service. This should | ||
// be set in case running as a service is not possible or desired even | ||
// though the current session is not detected to be interactive |
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.
atoulme
approved these changes
Dec 4, 2023
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.
Fix LGTM, it should be ported to the collector upstream as well.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Fix run as a service detection on Windows. Instead of trying to detect if it is a service or not, for which both
svc.IsAnInteractiveSession()
andsvc.IsWindowsService()
are somehow broken, try to run as a Windows service, if it fails fallback to run as an interactive process. This will add a small cost, which on my machine is under 5 microseconds, to startup in the interactive mode compared to using theNO_WINDOWS_SERVICE
environment variable. While this value seems fine for startup I'm keeping theNO_WINDOWS_SERVICE
option instead of deprecating it (it doesn't seem worth the trouble of deprecating it).Link to Splunk idea:
N/A
Testing:
Added benchmark to measure the cost of trying to start as a service (notice that when running as a service there is no extra cost).
Documentation:
Added entry in changelog.