warhawkreborn / connector_cli

Connector to allow discovery of servers (CLI version)
10 stars 5 forks source link

Windows: Run warhawkreborn as a background service #14

Open davidsummers opened 4 years ago

davidsummers commented 4 years ago

I just discovered a possible easy solution to running the warhawkreborn application as a service in Windows.

Checkout https://nssm.cc/ URL.

It allows a normal windows console program to be installed as a background service.

I've already tried this manually and it works fine on warhawkreborn.exe on Windows.

If you like this way of doing it, what is the best way to incorporate this into the installer for Windows?

Possibilities:

  1. Add nssm.exe to the warhawkreborn/connector_unix repo and add the scripts to the CMAKE/CPACK/NSIS installer to install and uninstall the service via nssm.exe.

  2. Incorporate the NSSM code into the warhawkreborn/connector_unix repo, build it and then install it when the warhawkreborn.exe program is installed and do the same thing as item 1 except the nssm.exe is built by the warhawkreborn build process instead of just using the binary.

  3. Something else?

What do you think?

Thalhammer commented 4 years ago

I don't know a lot about NSIS, but I don't really like to have binaries in the repo as in my experience it creates more problems than it solves. So option 2 sounds the best to me.

Did you check if NSIS allows Installing of a service on its own ? It sounds like a common task so it might already be integrated.

davidsummers commented 4 years ago

NSIS is just an installer and doesn't do anything else other than install files and run postinstall scripts, so it will need to be involved (to be able to run the postinstall script), but won't do the job for us.

I'll work this week on trying to integrate the NSSM source code in and then I should be able to tell NSIS to run the NSSM binary that was built from source and that will install the warhawkreborn.exe as a service running in background on Windows.

This makes it conceptually the same as on Linux where it runs in the background there and is controlled by the systemd (or can be disabled and run in foreground with just a few commands).

I would like to have the OPTION of putting the Windows program in a background server, at least.

Once there, of course, we'll eventually be able to control it more easily through a web server interface.

Obviously, when the package is uninstalled, it should de-register the background service.

I agree, I don't like stuff running in background without my OK, but I think it would be useful to have the option.

If the user choose foreground rather than background then it will just skip setting

I'll try to fix it up to do it both in foreground and in background.

I'll keep you posted.