-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add Windows Services support #394
base: main
Are you sure you want to change the base?
Conversation
👍 for adding generic host! It'll make a lot of future stuff such as configuration/metrics much cleaner. |
main/GarnetServer/Program.cs
Outdated
catch (Exception ex) | ||
var builder = Host.CreateEmptyApplicationBuilder(null); | ||
builder.Services.AddHostedService(sp => new GarnetService(args)); | ||
builder.Services.AddWindowsService(options => |
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.
As this says Windows service, just checking how does this work on Linux and other platforms?
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.
It does not affect other OS. AddWindowsServices
is a no-op on other OS.
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.
It's also no-op for if the process is not launched as service, see #394 (comment).
There is similar extension for Systemd integration (Microsoft.Extensions.Hosting.Systemd
).
Thank you for adding hosting capability for Garnet. To keep architecture clean and Garnet reusable by all parties, Garnet.Server standalone exe and hosting solution should ideally be separated (hosting should be a dedicated library in its own folder). This ensures the purity in terms of functionality of Garnet.Server, and do not unncessarily include redundant code in case other people have a different hosting strategy leveraging this standalone executable. Let me know what you think - I am happy to have a discussion, or provide a starting place where you can make contributions! |
We use As you can see when I publish the @yangmsft does it resolve your concerns? |
Ah right, if that's a concern for consumers of the standalone server then the guard has use 👍 The main server executable will be expected to get almost all of the dependencies in the screenshot above regarless, given future generic host & observability improvements to better align the Garnet with existing server application .NET practices (See ASP.NET, Orleans, Aspire, YARP..) |
My concern is on library/architectural design - GarnetServer as a project should be kept as strictly a library that produces standalone executable, for demo/exploration/proof-of-concept/other purposes. Hosting solutions should be placed in a dedicated folder (/hosting, for example), with a dedicated csproj for each hosting model. Even in the same operating system there can be multiple ways of hosting Garnet, and windows service is just one way of hosting and thus should be modeled as a standalone library. Otherwise we will eventually end up with a significant number of if statements in main() for each OS/hosting solution etc. that will be hard to maintain and introduce a lot of noise for anyone trying to use it. |
This is not true. We are using the extensible generic host provided by |
While In a sense |
This is fine for me. Windows service based hosting sample can be in its own project.
However I would like to hear more on this.. What in containerized solutions is not handled by generic host? How is this not problem for the ASP.NET/Orleans etc.? Why do they "require different implementation"? Doesn't the |
I might have misspoken and I apologize if I caused confusion; to my limited knowledge, I am not aware of containerized solution that actively deviates from |
I agree wholeheartedly.
I think the generic hosting model avoids the branching quite well but that's not the point here, the if statement in this case is just the most straightforward response at the moment to address your concerns about the redundant code (which is generic host & trimming concern). In my opinion, fully embracing generic host would get the best of both worlds. You could even hide that if statement behind the very flexible configuration abstraction which the generic host brings. I think using Generic Host in the standalone server would improve its configuration flexibility which I would imagine one wants from the main server binary. Garnet would also reap the benefits of the .NET DevDiv investments that are made to make this hosting solution AOT compatible (See Configuration Binder generator). The generic host would allow the in-process consumers of the Garnet to configure the server to their liking and hook it into their DI (like Orleans and other libraries, e.g. |
Instead of modifying |
@hez2010 - what do you think of this? thanks! |
Add Windows Services support.
Users can use
sc create "Microsoft Garnet Server" binPath=path/to/GarnetServer
to create a Windows Services so that it can be run in the background.Guarded under
OperatingSystem.IsWindows()
so it won't introduce any overhead for other OS.