Mar 8, 2018 11:52:14 AM seb leridon avatar   914

Create a Daemon

A daemon is a process that runs at regular intervals. Lutece has a centralized interface for managing daemons. Each daemon has its own frequency of execution. In addition, he must provide a report of the treatment carried out. This one is thus searchable in the daemons management interface.

Creating a Daemon class

The class must extend Lutece's Daemon class. The only method to implement is the run method within which you must call the setLastRunLogs method to pass the execution report to it.


/ **
 * My Daemon
 * /
public class MyDaemon extends Daemon
    / **
     * {@inheritDoc}
     * /
    public void run ()
        setLastRunLogs (MyProcess ());

Declare the daemon

The Daemon must be declared in 2 places:

Declaration in the XML file

This declaration defines the Java class of the daemon as well as the name and description of the daemon by its i18n keys (to manage the language of the user who consults the centralized interface).

<!-- Daemons -->

Declaration in the properties file

This statement is about daemon launch settings that can be changed frequently.

daemon.myDaemon.interval = 86400
daemon.myDaemon.onstartup = 1
These values ​​are by default in the properties file of the plugin, but they can be placed in any properties file read by Lutece (ex:

IMPORTANT From Lutece v4:

The values ​​in this file are read only for the first launch. These values ​​are then stored in the LUTECE Datastore and can only be modified by the centralized daemon management interface.