Tuesday, June 23, 2009

Starting Terracotta Server as a Windows service

There's an easy way to set up Terracotta server as Windows service using the open source Java Service Wrapper.

I've used their Integration Method 1, which uses a wrapper WrapperSimpleApp to run Terracotta server main class com.tc.server.TCServerMain.

First, just download and install the latest version wrapper-windows-x86-32-3.3.5. Then make copy of conf/wrapper.conf and name it TerracottaServer.conf.

Fill out these needed properties:

# for logging
wrapper.java.command.loglevel=INFO

# Method 1 main class
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

# classpath
# (1) is for WrapperSimpleApp
# (2) is for Terracotta Server - You'll need to fix up the path for your own use
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=d:/work/builds/terracotta-3.0.1/lib/tc.jar

# Java Additional Parameters
## NOTE: -server option only works with a JDK, not with JRE
wrapper.java.additional.1=-server
wrapper.java.additional.2=-XX:+HeapDumpOnOutOfMemoryError
wrapper.java.additional.3=-Dcom.sun.management.jmxremote
wrapper.java.additional.4=-Dtc.install-root=d:/work/builds/terracotta-3.0.1

# Initial Java Heap Size (in MB)
wrapper.java.initmemory=512

# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=512

# Application parameters. This is where you specify TC server main class
wrapper.app.parameter.1=com.tc.server.TCServerMain



That's pretty much all you need. There are Batch scripts in the "bin" folder of the wrapper installation where you can install/uninstall your service. Just make sure you modify those scripts to point to TerracottaServer.conf file you made earlier.

Once you have the service install, you can start/stop the service by using Windows services manager or by using the scripts. There will be a log of the run under "/logs"

I've made a copy of the scripts and the TerracottaServer.conf for easy tryout.
Post a Comment