2017 © Pedro Peláez
 

tao-extension extension-tao-scheduler

TAO job scheduler

image

oat-sa/extension-tao-scheduler

TAO job scheduler

  • Friday, July 27, 2018
  • by oat-lionel
  • Repository
  • 19 Watchers
  • 0 Stars
  • 754 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 16 Versions
  • 76 % Grown

The README.md

Tao task scheduler

RRULE standard is used to configure time and recurrence rule of each job., (*1)

Install

$ composer require oat-sa/extension-tao-scheduler

Usage

attach a job:

use oat\taoScheduler\model\scheduler\SchedulerServiceInterface;
$schedulerService = $this->getServiceManager()->get(SchedulerServiceInterface::SERVICE_ID);
$schedulerService->attach(
    'FREQ=MONTHLY;COUNT=5',                     //Reccurrence rule (repeat monthly, 5 times)  
    new \DateTime('2017-12-12 20:00:00'),       //Start date (time of first execution) 
    ['taoExtension/ServiceName', 'methodName']  //Callback to be called.
);

Also cron notation may be used:, (*2)

$schedulerService->attach(
    '* * * * *',                                //Reccurrence rule (repeat minutely)  
    new \DateTime('2017-12-12 20:00:00'),       //Start date (time of first execution) 
    ['taoExtension/ServiceName', 'methodName']  //Callback to be called.
);

Note:, (*3)

You can use any instance of callable type as callback except functions. In case if object is used ([$object, 'method']) make sure that object is instance of PhpSerializable.
Class name of oat\oatbox\action\Action instance may be used as a callback, (*4)

detach a job:

use oat\taoScheduler\model\scheduler\SchedulerServiceInterface;
$schedulerService = $this->getServiceManager()->get(SchedulerServiceInterface::SERVICE_ID);
$schedulerService->detach(
    'FREQ=MONTHLY;COUNT=5',                     //Reccurrence rule (repeat monthly, 5 times)  
    new \DateTime('2017-12-12 20:00:00'),       //Start date (time of first execution) 
    ['taoExtension/ServiceName', 'methodName']  //Callback to be called.
);

All given parameters to detach function should be the same as in existing job., (*5)

Run JobRunner

sudo -u www-data php index.php '\oat\taoScheduler\scripts\JobRunner' 1518006301 PT10S
  • First parameter is a timestamp from which scheduler should start to look up scheduled tasks. All the tasks scheduled before this time will be ignored.

Note:, (*6)

Scheduled tasks may be executed even if their start date is later than timestamp given to job runner because they may be recurred and their start date is just a time of the first occurrence, (*7)

If this parameter is omitted or less than 0 then start time will be taken from the storage (time of last seeking of scheduled job or time of last job runner iteration).
If there is no last iteration time in the storage current timestamp will be used., (*8)

  • Second parameter is time between Job Runner iterations. Default value is 60 seconds. This time may be longer than configured because execution of tasks found during current iteration may take some time.

Discover tasks to be run

sudo -u www-data php index.php '\oat\taoScheduler\scripts\tools\SchedulerHelper' show 1518097355 1518100955 

Remove expired jobs from job storage (jobs which will not be executed anymore after given date):

sudo php index.php '\oat\taoScheduler\scripts\tools\SchedulerHelper' removeExpiredJobs false 1519890884 
  • First parameter is dryrun mode. false by default.
  • Second parameter is time since which helper will try to find expired jobs (including given time). If parameter was not given then the last launch time of job runner will be used.

To run tasks through the task queue you may use \oat\taoTaskQueue\scripts\tools\AddTaskToQueue action.

Note:, (*9)

taoScheduler does not require taoTaskQueue extension. Make sure that task queue is installed., (*10)

use oat\taoTaskQueue\scripts\tools\AddTaskToQueue;
$schedulerService->attach(
    '*/5 * * * *',
    new DateTime('now', new \DateTimeZone('utc')),
    AddTaskToQueue::class,
    [ActionClassToBeRun::class, 'param 1', 'param2']
);

Warnings

  1. Configure JobRunner service with common rds storage in case if scheduler is going to be run on multiserver environment.
  2. Please do not schedule tasks which execution of which requires a lot of resource or take long time. All the time/resources consuming tasks should create appropriate tasks in the task queue. Ideally scheduled tasks should do nothing except adding tasks to the task queue.
  3. Use cron syntax in case if number of occurrences is not limited.
  4. iCalendar syntax is more flexible but in case of large or unlimited number of repeats there may be performance issues. By default limit of repeats is 732. More information: https://github.com/simshaun/recurr

The Versions

27/07 2018

dev-master

9999999-dev http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

27/07 2018

dev-develop

dev-develop http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

27/07 2018

v0.8.2

0.8.2.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

27/07 2018

dev-release-0.8.2

dev-release-0.8.2 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

27/07 2018

dev-fix-version-of-extension-installer

dev-fix-version-of-extension-installer http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

06/04 2018

v0.8.1

0.8.1.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

26/03 2018

dev-release-0.8.1

dev-release-0.8.1 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

26/03 2018

dev-fix/action_unit_test

dev-fix/action_unit_test http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

09/03 2018

v0.7.0

0.7.0.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

05/03 2018

dev-TT-303_remove_expired_jobs

dev-TT-303_remove_expired_jobs http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

26/02 2018

v0.5.2

0.5.2.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

23/02 2018

v0.5.1

0.5.1.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

09/02 2018

v0.3.1

0.3.1.0 http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

02/02 2018

dev-TAO-5875_scheduler_interfaces

dev-TAO-5875_scheduler_interfaces http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

01/02 2018

dev-TAO-5875_init_extension

dev-TAO-5875_init_extension http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment

30/01 2018

dev-TAO-5875_tao_scheduler

dev-TAO-5875_tao_scheduler http://www.taotesting.com

TAO job scheduler

  Sources   Download

GPL-2.0-only

The Requires

 

jobs scheduler tao oat computer-based-assessment