[Home] [Index] [Previous] [Next]

Command Line Oddjob

Using Oddjob without Oddjob Explorer.

Command Line Help

As we saw at the beginning of this manual how to run Oddjob from the command line. For further options use:

java -jar run-oddjob.jar -h

Additional arguments are passed into Oddjob and are set as the args property of the top Oddjob. If the command line is

java -jar run-oddjob -f greeting.xml "Hello World!"

and greeting.xml contained:

<oddjob id="oddjob">

Then the result would be:

Hello World!

Stopping Oddjob

Oddjob has a shutdown hook that attempts to stop Oddjob cleanly when the virtual machine detects it is being asked to terminate. Usually this happens with Ctr-C or the kill signal, but the exact implementation is machine dependent.

If a job is hanging and refuses stop Oddjob will forcibly exit after 5 seconds.

In the Linux Background

Oddjob comes with a server.xml that will start a server for use on a remote machine.

The following command will run Oddjob as a Linux background process.

nohup java -jar run-oddjob.jar -f server.xml &

Opening the corresponding client.xml file from Oddjob Explorer will allow jobs to be deployed to the server from the desktop using drag and drop or by changing the configuration directly on the server using Designer.

As a Windows Service

A quick 'Google' will reveal several projects for running a Java process as a service. The one we use is Procrun which is part of the Apache Daemon Project.

This script will download Procrun, install an Oddjob Service and start it:

                <properties environment="env">
                        <value key="work.dir" value="${oddjob.home}/work"/>
                        <value key="oddjob.bin.dir" value="${oddjob.home}/bin"/>
                        <value key="apache.daemon.version" value="1.3.1"/>
                        <value key="apache.daemon.zip.file" value="commons-daemon-${apache.daemon.version}-bin-windows.zip"/>
                        <value key="apache.daemon.host" value="dlcdn.apache.org"/>
                <mkdir dir="${work.dir}" name="Create Work Dir"/>
                <web:client name="Download Procrun" url="https://${apache.daemon.host}//commons/daemon/binaries/windows/${apache.daemon.zip.file}" xmlns:web="oddjob:web">
                        <file file="${work.dir}/${apache.daemon.zip.file}"/>
                <ant name="Ant Task to Unzip">
                                <unzip dest="${work.dir}" src="${work.dir}/${apache.daemon.zip.file}"/>
                <copy name="Copy procurun service exe" to="${oddjob.bin.dir}/OddjobService.exe">
                        <file file="${work.dir}/amd64/prunsrv.exe"/>
                <exec name="Install Service">${oddjob.bin.dir}/OddjobService.exe //IS 
"--DisplayName=Oddjob Server" 
"--Description=Oddjob Server" 
--StartMode=jvm --StopMode=jvm 
--StartMethod=main --StartParams=-f;${oddjob.home}\server-web.xml 
--StopClass=org.oddjob.launch.Launcher --StopMethod=stop 
--LogPath=${oddjob.home}\logs --LogLevel=TRACE --LogJniMessages=1
--StdOutput=auto --StdError=auto 
                <exec name="Start Service">${oddjob.bin.dir}/OddjobService.exe //ES
                        <exec name="Delete Service">${oddjob.bin.dir}/OddjobService.exe //DS

Note that the double quotes are required to use the environment variables.

Another option would be Java Service Wrapper.

When Things Go Wrong

By default Oddjob writes to a log file called oddjob.log which will be in the same directory that Oddjob was started from.

The logging configuration is in the log4j.properties file located in oddjob_dir/opt/class. Changing the logging level to debug may provide additional information.

[Home] [Index] [Previous] [Next]