Installing WebApp as service in Windows.. some questions...

I have been investigating this subject and I have a couple of questions…

1-I’ve read about installing the webapp as a service… is it a requisite or it is just recommended… ?

2-If it is in fact a requisite, then what’s the difference between using this tool http://nssm.cc/ and typing ‘sc create MyWebAppSvc type= own start= auto binpath= c:\Path\To\Exe\mywebapp.exe’ (as recommended in the Xojo docs) ?

3- In any case… what should be done in the event of a crash ? Would the service restart itself ?

Thanks a lot,
R

i goto command prompt (administrator mode) and do the following:

sc create yourwebapp binpath= d:\\data\\whateverfolder\\yourwebapp.exe

then open services and set yourwebapp to start automatically and goto the 3rd tab and set it to restart if it was down

NSSM works pretty nice. I created two BAT files. One to install the service and one to remove the service. NSSM has lots of options to set parameters for things like auto restart the service if it stops and other features.

When you need to install a new version run the BAT file to remove the service, copy the EXE and other “stuff” to the proper directory, then run the BAT file to reinstall the service.

SC probably would work too but I have not tried it.

Works very nice. The same way you can also run a console application as a service.

But the main question is “Is it necessary” ?
Will it fail if not run as a service?

No.
You can just open the port you’ve configured in you webapp and just launch it in a cmd-box.

Are there other benefits when running it as a service besides getting the app to restart automatically in the event of a crash ?

You don’t have to be logged on to run a service. Services are also run in the admin partition so have better access to local resources.

Thanks everybody for the feedback!

Roman

I’ve been running Web apps as a service on my Windows 2012R2 server for a while now.

I create batch files to start, stop, delete and install services between updates. The second thing I do is to run the Services app. Right-click on your service then click properties. Under General, I make the Startup type Automatic. Under the Recovery tab, I select Restart Service at First, Second and Subsequent failures. I set days to 0 and restart service after 1 minute.

INSTALL_SERVICE.BAT

@echo Creating a new Service for ICBW-PRF
sc create icbw-prf binpath= "c:\\services\\icbw-prf-3001\\icbw.exe --port=3001" start= auto displayname= _ICBW-PRF:3001_COMBUTS
@echo
@echo Starting ICBW-PRF
sc start icbw-prf
@pause

DELETE_SERVICE.BAT

@echo Stopping and Deleting ICBW-PRF
@echo Stopping ICBW-PRF
sc stop icbw-prf
@echo Deleting ICBW-PRF
sc delete icbw-prf
@pause

START_SERVICE.BAT

@echo Starting ICBW-PRF
sc start icbw-prf
@pause

STOP_SERVICE.BAT

@echo Stopping ICBW-PRF
sc stop icbw-prf
@pause

My only concern is that my Apps tend to crash if two browsers connect to the web app and interact with it at the same time. I Don’t know yet why this happens.

The better way would probably be to use XAMPP or WAMP and install ActivePerl or StrawberryPERL and then launch instances of every app where sessions are kept separate. This way my Apps don’t crash but does tend to use more memory. In the case of ActivePERL every instance use about 7M just for PERL and also increments your apps memory footprint with every browser that connects.

ps. Personally, I would prefer if I can figure out why the web app sessions crash when using services because the memory footprint is a lot less than going the PERL/XAMPP route.