Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUTECE-2213 : Add the possibility to trigger deamons using cron patte… #150

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

ThomasDumont
Copy link
Contributor

…rns with job scheduler service

@ThomasDumont
Copy link
Contributor Author

Currently on Lutece, daemons can only be executed at the moment of their activation and then at a fixed interval. When the tasks must be scheduled at specified times, one must use solutions outside the application (batch, external server, etc,) which makes the management of projects more complex (multiplication of logs, access points, etc,).
The purpose of this pull request is to easily manage DaemonTriggers with the quartz library. A DaemonTrigger is just a reference to a cron expression and to the daemon to trigger. DaemonTrigger management is done next to daemon management so it's possible to define several triggers for the same daemon.

@jonenst
Copy link
Member

jonenst commented Sep 7, 2018

@pierrelevy what do you think ?

@rzara
Copy link
Member

rzara commented Sep 9, 2018

@ThomasDumont about your first sentence : Daemons can also be executed when signaled, either manually from the manage daemon page, or from code (see LUTECE-2085). For instance, after mail is enqueued, the mail daemon is signaled so that the mail is sent as soon as possible.

I've not run your code yet, but it seems that you introduce a new, independent way of running daemons, whose configuration is hidden behind a button on the manage daemons page, which seems confusing to me. If I understand well, a daemon can be displayed as stopped on the manage daemons page, but run anyway because a cron trigger has been configured ?
Why not make interval and trigger be schedule options for daemons (I'm not sure if having both at the same time is a good idea, but intervals larger than 60 minutes are a pain with cron expressions, so...) ?
Then , on the manage daemons page, for each daemon you display:

  • the next scheduled run date is the daemon is active
  • a button to a schedule page if it's inactive, which allows to configure either a delay, or cron triggers

Finally, I think your DaemonJob class should call AppDaemonService.signalDaemon(key) instead of running the daemon directly. This way, you get several benefits :

  • if the daemon is already running, a new run will occur after the currently running one
  • if multiple events cause the daemon to be signaled simultaneously (or during a run), this signaling will be coalesced into one run
  • the daemon's log is displayed on the manage daemons page

@ThomasDumont
Copy link
Contributor Author

@rzara Thank you for your feedbacks.
Yes, with my code, a deamon can be displayed as not activated but be triggered anyway if a DaemonTrigger was defined. This is likely to bring some not expected treatments if users don't watch in the manage DaemonTrigger page whether a trigger exists for the not activated daemons.
In response to this issue, I think your suggestions are good. So I will :

  • merge the manage daemon page and the manage DaemonTrigger page with a schedule option (either a delay or a cron expression)
  • make the DaemonJob class call AppDaemonService.signalDaemon(key)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants