I currently manually run my web app as a service but it is a bit messy and I was wondering if anyone knows of a way to make a web app behave like a Windows Service app with the same options e.g. stop, start, restart etc.
Honestly, I have no direct experience. But one idea that comes to my mind: why not code a simple service application that starts/stops the WE app upon request? Kind of a helper app?
Thanks Alex, the issue is not so much being able to start and stop it from the service, it is that you have to fudge the app to make Windows think its a service. Also when the service stops I am not sure if the app.close event is fired or if it is just killing the app so for example I have some checks in my app.close event to check certain things before closing and do some tidying up.
Web apps are subclassed from ServiceApplication already, and I think you’ll find that these are already hooked up. If not, file a feature request.
I use nssm to run mine as a service. You can get it at nssm.cc
Nssm stands for non sucking service manager. You can also use sc.exe which is a windows command line utility for setting up a service.
Hi Nathan & Greg, Feedback case 29283 requests exactly this feature.
Regards.
there is a blog post on how to do so: link
I am currently running a web app as a service on a window server 2012 VM with no issues.
That looks exactly like what I am after.
The problem is that it is not a real service and if the app dies the service still says it is running so at the moment I have a special url handler that I have to have another program call and check for a response which is really messy. NSSM which Gary suggested looks like it monitors the app within the service and if it fails then it restarts and at least logs the errors to the event log so you can see what is going on.