• General
  • Installing LS as a service in Windows 2003 [UPDATED: see last post in thread]

Hi,

I've just installed LS on a Windows 2003 server. LS works fine when launched as an application, but fails (LS webserver can't be found) when installed as a service (using the batch file provided) even when I have correctly configured wrapper.conf. I also don't get any errors in the logs. What could I be doing wrong?

Thank you.

Patrick
Hi Patrick

Consider that the provided installation script does not also start the Server.
It does not even install it for an automatical start after reboot
(this last feature can be changed through the "wrapper.ntservice.starttype" property).

Did you try to start it manually from Windows "services" list?
In case you did, then may you please attach (or send to support@lightstreamer.com) the wrapper.log and Lightstreamer.log files produced?

Dario
9 months later
Was this ever resolved? I am too interested in managing Lightstreamer on Windows via a Windows service.

Chris
It seemed to be just a misunderstanding.
The "Install_LS_as_Service-NT.bat" adds the Server to the available services, ready to be started through the windows services manager (%SystemRoot%\system32\services.msc /s on my PC).
"peintre" presumably expected that "Install_LS_as_Service-NT.bat" would also run the Server.
So, I think that there's nothing to be resolved. Are you encountering any issues?
2 years later
I know the wrapper.exe (the Community version included at least) doesn't run 64bit Windows so I should use the SC.exe utility.

I can't quite figure the command out...Has anybody else done this successfully?
Actually, SC.EXE requires to create a special executable with the right hooks, which wraps the batch file. So it could not be the most viable solution.

There exist some possible alternatives (one of which we will probably choose for a future release of Lightstreamer after some testing):

+ Instead of Java Service Wrapper, use YAJSW (http://yajsw.sourceforge.net/).

+ Instead of Java Service Wrapper, use Java Service Launcher (http://jslwin.sourceforge.net/).

+ Install the batch file as a service through the Windows Resource Toolkit (http://support.microsoft.com/kb/137890).

+ Upgrade to the paid version of Java Service Wrapper (http://wrapper.tanukisoftware.org/doc/english/accountLicenses.jsp).
2 years later
With the release of Lightstreamer 4 the old service wrapper was substituted.
The new one supports 64 bit machines out of the box.

find more details about it in the LS_HOME/bin/windows/README.TXT file
5 months later
Hi,

I'm trying to install Lightstreamer Server version 4.0.1 build 1513.1.3 as service on windows server 2003 standard edition. I changed LS_HOME and JAVA_HOME in the ls.bat file. I executed the Start_LS_as_Application.bat and it was fine, but when I execute the Install_LS_as_Service-NT.bat the service is instaled correct but don't start. On the event viewer I can see that the service is trying to restart and the folowing logs is printed:

Event Type: Information
Event Source: nssm
Event Category: None
Event ID: 1008
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Started Install_LS_as_Service-NT.bat\..\LS.bat run for service Lightstreamer in Install_LS_as_Service-NT.bat\...

Event Type: Information
Event Source: nssm
Event Category: None
Event ID: 1023
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Killing process tree of process 2636 for service Lightstreamer with exit code 1


Event Type: Information
Event Source: nssm
Event Category: None
Event ID: 1027
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Killing PID 2636 in process tree of PID 2636 because service Lightstreamer is stopping.

Event Type: Information
Event Source: nssm
Event Category: None
Event ID: 1013
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Program Install_LS_as_Service-NT.bat\..\LS.bat for service Lightstreamer exited with return code 1.

Event Type: Information
Event Source: nssm
Event Category: None
Event ID: 1014
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Service Lightstreamer action for exit code 1 is Restart. Attempting to restart Install_LS_as_Service-NT.bat\..\LS.bat.

Event Type: Warning
Event Source: nssm
Event Category: None
Event ID: 1034
Date: 3/11/2011
Time: 16:34:39
User: N/A
Computer: SPOOLAPP0008
Description:
Service Lightstreamer ran for less than 1500 milliseconds. Restart will be delayed by 4000 milliseconds.

No log is generated by Lightstreamer itself.

Thanks,

Leonardo
can you please check in the logs folder under the lightstreamer installation: is there any log file there? Can you see any error message inside it?
We should check the console output of the LS.bat script when launched as a service.
I'm not sure if Windows or nssm allow you to do it in some way.
Anyway, you can try to setup a wrapper script that runs LS.bat and redirects the output.
For instance, create wrapper.batbeside LS.bat , which issues

.\LS.bat run > out.txt


and change Install_LS_as_Service-NT.batby replacing references to LS.bat with wrapper.bat;
then let's see the out.txt log generated.
I did as you suggested and no log was generated. If i run the wrapper.bat the log is generated, but when instaled as service no.
There must be some restriction with Windows services that we can't guess at the moment, or something in your deployment that is different from what we expect and that we still can't see.
But now you can remove Lightstreamer from the equation.
Please change wrapper.bat to issuing:

.\NOLS.bat > out.txt


and put NOLS.batbeside LS.bat , which just does:

echo test


Can you confirm that when you install the service you now see out.txt while you didn't see it in the previous attempts?
I did as you suggested and no log was generated. But this time i went futher. I tried to install the service without the Install_LS_as_Service-NT.bat. I ran "mssn.exe install Lightstreamer" and in the diolog that opened I chose my wrapper.bat then started the service manualy and the Lightstreamer started successfully.

This is the Install_LS_as_Service-NT.bat

@echo off
setlocal

rem
rem NSSM Lightstreamer NT service install script
rem

if "%OS%"=="Windows_NT" goto nt
echo This script only works with NT-based versions of Windows.
goto :end

:nt

echo Attention Windows Vista and Windows 7 users, this
echo script must be run as Administrator.
echo Once the service is installed, do not move nssm*.exe files!
echo ...
echo Please check the output below
echo ...

rem Remove the service
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto amd64nssm
goto x86nssm

:x86nssm
%0\..\nssm.exe install Lightstreamer %0\..\LS.bat run
goto :startserv

:amd64nssm
%0\..\nssm_x64.exe install Lightstreamer %0\..\LS.bat run
goto :startserv

:startserv
net start Lightstreamer

:end
pause

Thank you for finding the workaround.
Admittedly, we can't find an explanation for this behavior at the moment, as it doesn't replicate on our machines.
We will try to investigate and also ask for suggestions.
2 months later
While using "%0\.." to 'sort of' determine the path to the application, it does not work in all circumstances. For example if you open a command window, and navigate to the bin\windows directory, and run Install_LS_as_Service-NT.bat from there, the values entered into the registry for the service are incorrect as follows:

Parameters\AppDirectory = Install_LS_as_Service-NT.bat\..
Parameters\Application = Install_LS_as_Service-NT.bat\..\LS.bat

obviously that won't work.

Now if you double click Install_LS_as_Service-NT.bat from windows explorer, you'll end up with this (which does work - although I wouldn't call this a very elegant solution - having the script filename in the path):

Parameters\AppDirectory = C:\Lightstreamer\bin\windows\Install_LS_as_Service-NT.bat\..
Parameters\Application = C:\Lightstreamer\bin\windows\Install_LS_as_Service-NT.bat\..\LS.bat

Seems like the Install_LS_as_Service-NT.bat scrip needs some work.

What really needs to be in the Registry is (to be nice and clean):

Parameters\AppDirectory = C:\Lightstreamer\bin\windows
Parameters\Application = C:\Lightstreamer\bin\windows\LS.bat

This can be accomplished by changing the script as follows:
@echo off
setlocal

rem
rem NSSM Lightstreamer NT service install script
rem

if "%OS%"=="Windows_NT" goto nt
echo This script only works with NT-based versions of Windows.
goto :end

:nt

echo Attention Windows Vista and Windows 7 users, this
echo script must be run as Administrator.
echo Once the service is installed, do not move nssm*.exe files!
echo ...
echo Please check the output below
echo ...

rem Remove the service
if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto amd64nssm
goto x86nssm

:x86nssm
%~dp0\nssm.exe install Lightstreamer %~dp0%LS.bat run
goto :startserv

:amd64nssm
%~dp0\nssm_x64.exe install Lightstreamer %~dp0%LS.bat run
goto :startserv

:startserv
net start Lightstreamer

:end
pause
And now will work from either the command window, or windows explorer.
Thank you for pointing out the subtleties of the "%0\.." form.
Actually, we assumed that the "%~" forms might not be supported everywhere, but the assumption was probably wrong, or it is now obsolete.
We will apply your suggestion on the next release.