TLeonardUK / ds3os

Dark Souls - Open Server
MIT License
708 stars 114 forks source link

[Feature] Implementing ServiceMain in Server.exe? #73

Open TLeonardUK opened 2 years ago

TLeonardUK commented 2 years ago

Discussed in https://github.com/TLeonardUK/ds3os/discussions/72

Originally posted by **rscales2929** February 1, 2022 Hi, are there any plans to implement ServiceMain in Server.exe, allowing it to run as a Windows service? I'm not a professional C++ dev, but it seems like it would fit right into Entry.cpp. Right now you can get a t2.micro Amazon AWS EC2 Windows Server 2019 instance for free, meaning those inclined to put in the leg work can set up a hosted DS3 Open Server. They can keep it running for 750 hours/month at no cost. To me, this is infinitely preferable to opening my personal computer to the Internet. I used NSSM to create a wrapper for Server.exe on my EC2 instance, but being able to run DS3OS directly as a service would be preferable. (Btw, happy to share my AMI for those interested in spinning up their own instances.)
FracturedShader commented 1 year ago

I put together a working sample of this on my fork: https://github.com/FracturedShader/ds3os/tree/feature/run-as-service

There are a few TODOs left before it is fully ready, but the main goal was to preserve all current functionality precisely as it is while enabling the ability to register the server as a service. This way it can be run directly (how it currently works), or as a service without any special configurations on the part of the user.

Remaining TODOs:

If the approach so far seems reasonable it should be possible to handle these remaining items in a fairly straightforward way so long as we assume anyone doing this is comfortable with manipulating Windows Services.