#1 2016-05-31 00:21:57

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

how to make mORMot scheduled jobs running

how to make mORMot scheduled jobs running like cron , windows schedule , mysql event?


Jongruk Aripoo

Offline

#2 2016-05-31 06:22:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: how to make mORMot scheduled jobs running

Try TSynBackgroundThreadProcess

See http://synopse.info/files/html/api-1.18 … EADPROCESS

Offline

#3 2016-05-31 06:31:19

xchinjo
Member
From: Thailand
Registered: 2016-04-29
Posts: 41
Website

Re: how to make mORMot scheduled jobs running

thank you.


Jongruk Aripoo

Offline

#4 2021-03-11 18:15:53

leus
Member
Registered: 2012-09-05
Posts: 79

Re: how to make mORMot scheduled jobs running

I'm trying to come up with a solution for this (by the way, the updated documentation link is now https://synopse.info/files/html/api-1.1 … ADPROCESS).

Do anybody have some sample code that allows to program task to run at a *specific* time every day?

Offline

#5 2021-03-12 07:28:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: how to make mORMot scheduled jobs running

Just use a TSynBackgroundTimer https://synopse.info/files/html/api-1.1 … ROUNDTIMER - mORMot 2 it is located in mormot.core.threads.pas.

With a resolution of 1 minute for instance, then a local field with the next trigerring time, and if current time is >= than this time, run the task and update the trigerring time.

Offline

#6 2021-03-12 07:36:42

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: how to make mORMot scheduled jobs running

Scheduler from the now-disappeared-but-has-a-backup-on-github CromisLibrary is the best for such a task as far as I know.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#7 2021-03-12 07:44:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: how to make mORMot scheduled jobs running

The CromisLibrary scheduler seems to use the Windows or LCL timer. So it is not very suitable for a daemon/server with no main loop.

What is wrong with:

  FNextTrigger: TDateTime;
  ...
procedure TMyProcessingClass.RunEveryMinute(
...
  if NowUtc > FNextTrigger then 
  begin
    DoSomething();
    FNextTrigger := FNextTrigger + 1; // see U tomorrow
  end;

Offline

#8 2021-04-06 08:50:41

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: how to make mORMot scheduled jobs running

ab wrote:

The CromisLibrary scheduler seems to use the Windows or LCL timer. So it is not very suitable for a daemon/server with no main loop.

Actually Cromis Scheduler uses a separated thread to perform the loop:
https://github.com/CPsoftBE/BackupOfCro … .pas#L1048


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB