-
Notifications
You must be signed in to change notification settings - Fork 15
Invocation
This page describes how to invoke a daemon written using the Daemon library. Specifically, it documents the built-in commands and their options.
The built-in commands allow you to start, shut down, and check daemon instances. (All other commands are sent to the running daemon process, where they will be handled by the handleCommand()
method of the IDaemon subclass.)
In the syntax examples, jarname is the jar file that contains your daemon, and options refers to standard options.
The following options can be used with the built-in commands.
--instance=instanceName
Apply the command to the instance called instanceName. If this option is not used, then the default instance name (as returned by the getDefaultInstanceName()
method of the DaemonController subclass) is used.
--stdoutLog=filename
Use the given filename as the stdout log (the log file that captures the stdout and stderr of the daemon.)
--jvmOptions=options
Use the given JVM options when starting the daemon process.
These are the built-in commands. (In the synopses below, options refers to the options described in the previous section.)
java -jar jarname options start
Start a daemon instance.
java -jar jarname options shutdown
Shut down a daemon instance.
java -jar jarname options check
Check whether a daemon instance is running.
java -jar jarname options poke
Check whether a daemon instance is running, and restart it if it is not running. This command is meant to be run periodically (e.g., from a cron job) to restart the daemon in the event of a crash, reboot, etc.
Here are some examples. The examples assume that your application is a single executable jar file called myApp.jar
.
java -jar myApp.jar start
Start the default instance of the daemon.
java -jar myApp.jar shutdown
Shut down the default instance of the daemon.
java -jar myApp.jar poke
Check whether the default instance of the daemon is running, and if not, start it.
java -jar myApp.jar --instance=foobar start
Start an instance of the daemon using "foobar" as the instance name. You can have any number of instances of the same daemon running as long as they all have different instance names.
java -jar myApp.jar --instance=foobar shutdown
Shut down the instance of the daemon that has the instance name "foobar".
java -jar myApp.jar --jvmOptions="-Xmx1024m -XX:-OmitStackTraceInFastThrow" start
Start the default instance of the daemon, specifying some JVM options.