GigaSpaces as Windows Service
Common Scenarios
GigaSpaces infrastructure can be started using a GigaSpaces Grid Service Agent as explained in GSA page. When using Windows based OS for running GigaSpaces infrastructure, users want to convert GSA Grid Service Agent. This is a process manager that can spawn and manage Service Grid processes (Operating System level processes) such as The Grid Service Manager, The Grid Service Container, and The Lookup Service. Typically, the GSA is started with the hosting machine's startup. Using the agent, you can bootstrap the entire cluster very easily, and start and stop additional GSCs, GSMs and lookup services at will. into a windows service for following common reasons,
- GSA process should survive a user logoff.
- GSA command windows should be hidden so that they are not closed accidentally by users.
- GSA process should restart automatically after a machine restart and all GigaSpaces infrastructure should be available without user/administrator intervention.
psexec
If your requirement is only item 1 and/or 2 above, you can use psexec (SysInternals/Microsoft tool, http://technet.microsoft.com/en-us/sysinternals/bb897553). When you start the GSA using psexec from a remote machine in the network the process does not open command windows and does not get terminated on a logoff of the user.
Windows Service
If you need to fulfill all 3 reasons above, then you have to create a windows service for GSA.
Easiest way to convert GSA into service is to use the .NET version of the product and create windows service using the instructions that are documented in the XAP.NET installation documentation.
Some users are not comfortable using the .NET version of the product and want to use only Java version of the product. In such cases, there are many software that can help in converting a Java Application (like GigaSpaces) to a Windows Service.
Example
An example GSA windows service configuration created using Java Service Wrapper can be downloaded from here. It was created using the instructions on Tanuki software website.
-
Modify the wrapper.config file per your environment. For downloading wrapper.jar go to Java Service Wrapper, download wrapper-windows-xxx-xx-x.x.xx-pro.zip which fits to your platform, unzip it and copy wrapper-windows-xxx-xx-x.x.xx-pro\lib\wrapper.jar to your myApp\lib dir (or to any dir on your file system and point to it in your classpath)
-
Set the values for all the environment variables (look for set.xxx) per your environment.
-
This example starts 2 GSC Grid Service Container. This provides an isolated runtime for one (or more) processing unit (PU) instance and exposes its state to the GSM.'s, GSM Grid Service Manager. This is is a service grid component that manages a set of Grid Service Containers (GSCs). A GSM has an API for deploying/undeploying Processing Units. When a GSM is instructed to deploy a Processing Unit, it finds an appropriate, available GSC and tells that GSC to run an instance of that Processing Unit. It then continuously monitors that Processing Unit instance to verify that it is alive, and that the SLA is not breached. and a LUS Lookup Service. This service provides a mechanism for services to discover each other. Each service can query the lookup service for other services, and register itself in the lookup service so other services may find it.. Modify these settings as needed.
-
Also modify Additional Java parameters (look for wrapper.java.additional.xxx) defined in the wrapper.config file.
-
Install the service using the included
InstallGSAService-NT.bat
script. -
After the install you should be able to see the service in the Windows Services applet.
-
Service is installed with Startup Type of "Manual". Change it to "Automatic" to start the service automatically after every restart.
-
Use the
UninstallGSAService-NT.bat
script to uninstall the service.
Other Information
- It is recommended that the
deploy
command be run manually instead of defining this as a windows service. - Typically, GigaSpaces cluster spans multiple machines and redundant instances of GSM's and LUS's run on different machines. If a machine is restarted, deployment will still be intact and be managed by available redundant GSM that is running on other machine. Once the machine and GSC's are restarted missing PU This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity. instances are deployed by GSM into these newly started GSC's as needed.
- To convert other individual components (GSC, GSM or LUS) into windows service, same instructions can be used with simple modifications.