Page 1 of 2

Windows Service

Posted: Thu Oct 08, 2015 4:13 pm
by Staj
Providing an inbuilt Windows Service for Virtual Radar Server would be handy but at least fixing headless mode to support console redirection so we can use existing service wrappers would be good.

VirtualRadar.Headless.View.MainView.ShowView() uses Console.ReadKey() which throws an exception when used with a service wrapper that utilises console redirection, using a different function and capturing Ctrl-C instead of reading for Q would be more helpful (even if enabled only by an extra command line argument).

Re: Windows Service

Posted: Sun Oct 11, 2015 4:02 am
by agw
The problem is that WinForms programs won't write console output to the console that they're started from, I need to start a new console to get anything displayed. I can add another switch to disable all output, however you'd need some mechanism to get it to shut down cleanly when the service is stopped. It would probably be better to have a separate executable that can run as a service and can pick up configuration changes from a GUI mode instance via a named pipe between the two.

I'll add it to the list :)

Re: Windows Service

Posted: Sun Oct 11, 2015 4:54 am
by Staj
That's interesting because the service wrapper I used was able to capture the console output as expected up until that exception was thrown. I might try making some changes when I get time and see if I can get it to work with the service wrapper.

Re: Windows Service

Posted: Sun Oct 11, 2015 6:07 am
by agw
VRS in headless mode looks to see if has a console attached. If you start VRS from the command line it won't have one, because WinForms applications don't attach to the console that started them, so it has to create a new console and attaches that to the process.

However, if VRS detects that there is a console already attached to the process then it won't do anything special, it'll just use that console. I'm guessing that your wrapper is attaching a console and is supplying stdout and maybe stderr.

If your wrapper could be told to also attach a stdin and to send "Q" down it when the service is being stopped then that should do the trick. It needs to do something to tell VRS to shut down cleanly.

When the service runs you won't be able to run VRS in GUI mode unless you force VRS to run with multiple instances by using the -workingFolder switch and specifying the configuration folder. However, if you use the GUI instance to change the configuration then the service instance won't know that it's been changed, you'll have to restart it to pick up the new configuration. Both instances could also get into a fight with each other when the time comes to download the latest routes, but that will come down to the times that each instance was started as checks for fresh routes are made hourly after startup. Ideally though there needs to be some cooperation from both sides to stop them getting in each other's way.

Re: Windows Service

Posted: Sun Oct 11, 2015 7:16 am
by Staj
Ah, misunderstood, I was assuming you were talking about headless mode as well. I'm aware of the limitations was just confused. My deployment will be on Windows Server instances, maybe even Core. I still need to go through the VRS source and pickup the coding style (I'm assuming there isn't a style guide) but I imagine we'll at least be creating some plugins to suit our needs.

Re: Windows Service

Posted: Wed Nov 04, 2015 5:25 pm
by TurboCommander
I found this after several attempts at trying to run VRS as a service. You are talking about more than I understand above but I'll vote for figuring out how to run VRS as a Windows service. Thanks!

Re: Windows Service

Posted: Wed Jan 06, 2016 10:14 am
by Staj
Finally got a chance to look at the code and I see what you mean, is this on your list any time soon? I might take a crack at writing a wrapper Windows service if it isn't.

Re: Windows Service

Posted: Wed Jan 06, 2016 11:33 am
by agw
I'm doing the web admin plugin at the moment. Once that's done (it's going to take a while) then I'll take a look at the whole running VRS as a service thing. Being able to configure the server via the browser would solve the problem of configuring the service.

Re: Windows Service

Posted: Thu Aug 11, 2016 7:55 pm
by Staj
That Web Plugin is looking nifty, it looks like we're moving towards being able to manage it remotely via web and shell.

Re: Windows Service

Posted: Sat Aug 13, 2016 11:18 pm
by agw
The plan for version 3 is to have a core that can be loaded in different ways. One of those ways will be as a Windows service.