Navigation



Documentation

Table of contents

  1. Configuration
  2. Logging
  3. Scripts

Configuration

JExecDaemon uses a simple XML based configuration file. The configuration file that ships with JExecDaemon is filled with example data and needs to be edited before first use.

Below is a copy of the default configuration file:

<Config xmlns="http://www.unlogic.se/projects/jexecdaemon/1.0/schemas/config"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.unlogic.se/projects/jexecdaemon/1.0/schemas/config config.xsd">

    <ShutdownSocket>
        <Port>25000</Port>
        <Password>secret</Password>
    </ShutdownSocket>

    <Executors>
        <Executor>
            <Name>LM Sensors</Name>
            <Port>25001</Port>
            <Command>/usr/bin/sensors</Command>
        </Executor>
        <Executor>
            <Name>HDDTemp</Name>
            <Port>25002</Port>
            <Command>hddtemp</Command>
            <Arguments>
                <Argument>/dev/sda</Argument>
                <Argument>/dev/sdb</Argument>
                <Argument>/dev/sdc</Argument>
                <Argument>/dev/sdd</Argument>
            </Arguments>
            <WorkingDirectory>/usr/bin</WorkingDirectory>
            <Timeout>5000</Timeout>
        </Executor>       
    </Executors>
</Config>

The path to the configuration file is be given as a command line parameter to JExecDaemon upon start up this enables multiple instances of JExecDaemon to be run using the same installation. The default start and stop scripts that ship with JExecDaemon use the following configuration file "conf/config.xml".

The configuration file is divided into two main elements, <ShutdownSocket> and <Executors>. The <ShutdownSocket> element contains global configuration entries that are specific to the shutdown of JExecDaemon while the <Executors> element contains <Executor> elements which map a address and port to a given command.

The <ShutdownSocket> element may/must contains the following sub elements:

Element name Value Required occurrence
Address Valid host or IP address no, defaults to 0.0.0.0 (listens to all interfaces) 0..1
Port 0-65535 yes 1
Password The password needed to shutdown JExecDaemon, this is read automatically from the default configuration file by the stop.sh/stop.bat scripts yes 1

 The <Executors> element must contain at least one <Executors> element, containing the following sub elements:

Element name Value Required occurrence
Name The name of the executor (used for logging) yes 1
Address Valid host or IP address no, defaults to 0.0.0.0 (listens to all interfaces) 0..1
Port 0-65535 yes 1
Command String yes (the command to be executed) 1
Timeout 1 - 2^63-1 no (controls how low long a process is allowed to execute before it is terminated) 0..1
WorkingDirectory Working directory no 0..1
Arguments One or more <Argument> elements no 0..1

In order to pass command line parameters to an executor a <Arguments> element can be added containing <Argument> elements (see the example configuration file above).

For more detailed information about the configuration file of JExecDaemon see the "config.xsd" schema located in the conf directory.

Logging

JExecDaemon uses the very popular and widespread log4j logging library. The path to the log4j configuration file (in XML format) is given as a command line parameter to JExecDaemon upon start up. The default start script that ship with JExecDaemon uses the following logging configuration file "conf/log4j.xml".

For more information about how to use and configure log4j, head over to the log4j website.

By default JExecDaemon is configured to log events on level "INFO" or higher and place the log file at "logs/jexecdaemon.log".

Scripts

JExecDaemon ships with the following scripts (found in the bin directory) in both batch and shell script formats: 

Name Description
start.bat/start.sh Starts JExecDaemon using the configuration file "conf/config.xml" and logging configuration file "conf/log4.xml"
stop.bat/stop.sh Stops JExecDaemon using the values of the ShutdownSocket specified in the configuration file "conf/config.xml"
test.bat/test.sh Used for testing individual executors, takes a host and port as command line parameters. The data received from the executor is written to standard out.

A simple init script is also included for Linux/Unix based systems, it's called "jexecdaemon" and is located in the docs directory.

 Threads

 JExecDaemon is multithreaded and each executor is given a single thread. This enables all executors in a JExecDaemon instance to be executed simultaneously but it also protects from DOS attacks since it prevents a single executor from being executed concurrently.