Skip to content

Commit

Permalink
Merge pull request pkp#738 from touhidurabir/i9678_main
Browse files Browse the repository at this point in the history
pkp/pkp-lib#9678 Replacing task schedular with laravel scheduler
  • Loading branch information
touhidurabir authored Jul 31, 2024
2 parents be5949d + ae2f9e5 commit 77d083c
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 113 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
[submodule "plugins/generic/citationStyleLanguage"]
path = plugins/generic/citationStyleLanguage
url = https://github.com/pkp/citationStyleLanguage.git
[submodule "plugins/generic/acron"]
path = plugins/generic/acron
url = https://github.com/pkp/acron
[submodule "plugins/generic/webFeed"]
path = plugins/generic/webFeed
url = https://github.com/pkp/webFeed.git
18 changes: 0 additions & 18 deletions classes/plugins/PubObjectsExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function register($category, $path, $mainContextId = null)

$this->addLocaleData();

Hook::add('AcronPlugin::parseCronTab', [$this, 'callbackParseCronTab']);
foreach ($this->_getDAOs() as $dao) {
if ($dao instanceof SchemaDAO) {
Hook::add('Schema::get::' . $dao->schemaName, $this->addToSchema(...));
Expand Down Expand Up @@ -532,23 +531,6 @@ protected function _getObjectAdditionalSettings()
return [$this->getDepositStatusSettingName()];
}

/**
* @copydoc AcronPlugin::parseCronTab()
*/
public function callbackParseCronTab($hookName, $args)
{
$taskFilesPath = & $args[0];

$scheduledTasksPath = "{$this->getPluginPath()}/scheduledTasks.xml";

if (!file_exists($scheduledTasksPath)) {
return false;
}

$taskFilesPath[] = $scheduledTasksPath;
return false;
}

/**
* Retrieve all unregistered preprints.
*
Expand Down
36 changes: 36 additions & 0 deletions classes/scheduler/Scheduler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* @file classes/scheduler/Scheduler.php
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class Scheduler
*
* @brief Core scheduler class, responsible to register scheduled tasks specific for the application
*/

namespace APP\scheduler;

use APP\tasks\UsageStatsLoader;
use PKP\scheduledTask\PKPScheduler;

class Scheduler extends PKPScheduler
{
/**
* @copydoc \PKP\scheduledTask\PKPScheduler::registerSchedules
*/
public function registerSchedules(): void
{
parent::registerSchedules();

$this
->schedule
->call(fn () => (new UsageStatsLoader([]))->execute())
->daily()
->name(UsageStatsLoader::class)
->withoutOverlapping();
}
}
41 changes: 36 additions & 5 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
; To set the "Secure" attribute for the cookie see the setting force_ssl at the [security] group
session_samesite = Lax

; Enable support for running scheduled tasks
; Set this to On if you have set up the scheduled tasks script to
; execute periodically
scheduled_tasks = Off

; Site time zone
; Please refer to https://www.php.net/timezones for a full list of supported
; time zones.
Expand Down Expand Up @@ -581,6 +576,42 @@
; Remove this setting to leave failed jobs in the database.
delete_failed_jobs_after = 180


;;;;;;;;;;;;;;;;;;;;;;;;;;
; Schedule Task Settings ;
;;;;;;;;;;;;;;;;;;;;;;;;;;

[schedule]

; Whether or not to turn on the built-in schedule task runner
;
; When enabled, schedule tasks will be processed at the end of each web
; request to the application.
;
; Use of the built-in schedule task runner is highly discouraged for high-volume
; sites. Use your operational system's task scheduler instead, and configure
; it to run the task scheduler every minute.
; Sample for the *nix crontab
; * * * * * php lib/pkp/tools/scheduler.php run >> /dev/null 2>&1
;
; See: <link-to-documentation>
task_runner = On

; How often should the built-in schedule task runner run scheduled tasks at the
; end of web request life cycle (value defined in seconds).
;
; This configuration will only have effect for the build-it task runner, it doesn't apply
; to the system crontab configuration.
;
; The default value is set to 60 seconds, a value smaller than that might affect the
; application performance negatively.
task_runner_interval = 60

; When enabled, an email with the scheduled task result will be sent only when an error
; has occurred. Otherwise, all tasks will generate a notification.
scheduled_tasks_report_error_only = On


[invitations]
expiration_days = 3

Expand Down
1 change: 0 additions & 1 deletion dbscripts/xml/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<migration class="PKP\migration\install\InvitationsMigration" />
<migration class="PKP\migration\install\ReviewFormsMigration" />
<migration class="PKP\migration\install\SubmissionFilesMigration" />
<migration class="PKP\migration\install\ScheduledTasksMigration" />
<migration class="PKP\migration\install\LibraryFilesMigration" />
<migration class="PKP\migration\install\ReviewsMigration" />
<migration class="PKP\migration\install\TemporaryFilesMigration" />
Expand Down
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<migration class="PKP\migration\upgrade\v3_5_0\PreflightCheckMigration" fallback="3.4.9.9" />
<migration class="APP\migration\upgrade\v3_5_0\I8333_AddMissingForeignKeys" />
<migration class="PKP\migration\upgrade\v3_5_0\I9895_AddAppKeyToConfigFile"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9678_RemoveScheduledTasksTable"/>
<migration class="PKP\migration\upgrade\v3_5_0\InstallEmailTemplates"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9197_MigrateAccessKeys"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9253_SiteAnnouncements"/>
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes/README-3.5.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ New config.inc.php parameters added for security:
- cipher (default value: ''), cipher algorithm used to generate app key and encryption purpose
- cookie_encryption (default value: ''), allow cookie encryption when set

New config.inc.php section for schedule task named schedule is added, with the following parameters:
- task_runner (default value: On), Whether or not to run the schedule tasks through web based task runner
- task_runner_interval (default value: 60), How often should the built-in web based task runner run scheduled tasks in seconds
- scheduled_tasks_report_error_only (default value: On), Whether or not schedule task execution failure details will be sent via mail

- The setting general.scheduled_tasks has been removed. It was supposed to control the schedule tasks but had no impact.

New Features
------------
Expand Down
2 changes: 1 addition & 1 deletion lib/pkp
1 change: 0 additions & 1 deletion plugins/generic/acron
Submodule acron deleted from cb707f
58 changes: 0 additions & 58 deletions registry/scheduledTasks.xml

This file was deleted.

26 changes: 0 additions & 26 deletions tools/runScheduledTasks.php

This file was deleted.

0 comments on commit 77d083c

Please sign in to comment.