Skip to content
David Hovemeyer edited this page Apr 12, 2014 · 2 revisions

See the ExampleDaemon and ExampleDaemonController classes as an example of how to define a daemon. The ExampleDaemon class has methods for starting the daemon, shutting down the daemon, and receiving commands. The ExampleDaemonController is an example of an entry point class: for example, if you are doing a single-jar deployment, it would be the main class.

Running the example daemon: first compile the classes (will happen automatically if you import the project into Eclipse, or you can run ant build). Then cd to the root directory of the project. Run the following commands:

./mkdemojar.sh
java -jar demo.jar start
java -jar demo.jar hello
java -jar demo.jar shutdown

The example shows how you might package your daemon in a single jar file for deployment. The last three commands will (respectively) start the daemon, send a command ("hello") to the daemon, and shut down the daemon. A file called log.txt will be created to capture the standard output and standard error of the daemon. Each command (start/hello/shutdown) will be logged in this file.

Clone this wiki locally