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

pkp/pkp-lib#9678 Replacing task schedular with laravel scheduler #1657

Merged
merged 7 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions classes/scheduler/Scheduler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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;
use PKP\task\EditorialReminders;
use PKP\task\PublishSubmissions;
use PKP\task\ReviewReminder;

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

$this
->schedule
->call(fn () => (new ReviewReminder())->execute())
->hourly()
->name(ReviewReminder::class)
->withoutOverlapping();

$this
->schedule
->call(fn () => (new EditorialReminders())->execute())
->daily()
->name(EditorialReminders::class)
->withoutOverlapping();

$this
->schedule
->call(fn () => (new PublishSubmissions())->execute())
->daily()
->name(PublishSubmissions::class)
->withoutOverlapping();

$this
->schedule
->call(fn () => (new UsageStatsLoader([]))->execute())
->daily()
->name(UsageStatsLoader::class)
->withoutOverlapping();
}
}
46 changes: 35 additions & 11 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +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

; Scheduled tasks will send email about processing
; only in case of errors. Set to off to receive
; all other kind of notification, including success,
; warnings and notices.
scheduled_tasks_report_error_only = On

; Site time zone
; Please refer to https://www.php.net/timezones for a full list of supported
; time zones.
Expand Down Expand Up @@ -583,6 +572,41 @@
; 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\SubmissionFilesMigration" />
<migration class="PKP\migration\install\ReviewFormsMigration" />
<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 @@ -115,6 +115,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
7 changes: 7 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,13 @@ 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
3 changes: 0 additions & 3 deletions locale/en/manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,6 @@ msgstr "Review Options"
msgid "manager.setup.reviewOptions.automatedReminders"
msgstr "Automated Email Reminders"

msgid "manager.setup.reviewOptions.automatedRemindersDisabled"
msgstr "To activate these options, the site administrator must enable the <tt>scheduled_tasks</tt> option in the OMP configuration file. Additional server configuration may be required to support this functionality (which may not be possible on all servers), as indicated in the OMP documentation."

msgid "manager.setup.reviewOptions.onQuality"
msgstr "Editors will rate reviewers on a five-point quality scale after each review."

Expand Down
2 changes: 1 addition & 1 deletion plugins/generic/acron
Submodule acron updated 1 files
+13 −13 AcronPlugin.php
69 changes: 0 additions & 69 deletions registry/scheduledTasks.xml

This file was deleted.

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

This file was deleted.