Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
FIX: Slow to cron rate
Browse files Browse the repository at this point in the history
The jobs are taking more than an hour to run, so running them hourly
isn’t practical.
  • Loading branch information
Sam Minnee committed Nov 16, 2017
1 parent 0359124 commit 4b57b0c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 56 deletions.
27 changes: 0 additions & 27 deletions mysite/code/crons/BuildAddonsCron.php

This file was deleted.

27 changes: 0 additions & 27 deletions mysite/code/crons/CacheHelpfulRobotDataCron.php

This file was deleted.

37 changes: 37 additions & 0 deletions mysite/code/crons/NightlyUpdatesCron.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/**
* These nightly updates can clean up anything that might have been missed by the other tasks
*/
class NightlyUpdatesCron implements CronTask
{

/**
* Run at 1am every morning
*
* @return string
*/
public function getSchedule()
{
return "0 1 * * *";
}

/**
* Run the build task CacheHelpfulRobotDataTask
* @return void
*/
public function process()
{
$taskClasses = [
[BuildAddonsTask::class, null], // rebuild all addons
[CacheHelpfulRobotDataTask::class, null], // fetch helpful robot data
];

foreach ($taskClasses as $taskInfo) {
list($taskClass, $taskQuerystring) = $taskInfo;
$job = new RunBuildTaskJob($taskClass, $taskQuerystring);
$jobID = Injector::inst()->get(QueuedJobService::class)->queueJob($job);
echo 'Added ' . $taskClass . ' to job queue (job ID ' . $jobID . ")\n";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

use SilverStripe\Elastica\ReindexTask;

/**
* These regular updates run as often as is practical.
* They seem to take 2-3 hours at the moment, so we run them 4 times per day.
*/
class SilverStripeElasticaReindexCron implements CronTask
{

/**
* Run hourly, on the hour
* Run every 6 hours
*
* @return string
*/
public function getSchedule()
{
return "0 * * * *";
return "0 */6 * * *";
}

/**
Expand Down

0 comments on commit 4b57b0c

Please sign in to comment.