From dd6d6e3523fe7bce5c9d77d84b793c799e2a8d61 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 30 Jul 2024 15:07:23 +0600 Subject: [PATCH 1/5] pkp/pkp-lib#9678 Laravel scheduler implementation## --- classes/plugins/PubObjectsExportPlugin.php | 18 ------- classes/scheduler/Scheduler.php | 36 ++++++++++++++ config.TEMPLATE.inc.php | 41 +++++++++++++-- dbscripts/xml/install.xml | 1 - dbscripts/xml/upgrade.xml | 1 + docs/release-notes/README-3.5.0 | 6 +++ registry/scheduledTasks.xml | 58 ---------------------- tools/runScheduledTasks.php | 26 ---------- 8 files changed, 79 insertions(+), 108 deletions(-) create mode 100644 classes/scheduler/Scheduler.php delete mode 100644 registry/scheduledTasks.xml delete mode 100644 tools/runScheduledTasks.php diff --git a/classes/plugins/PubObjectsExportPlugin.php b/classes/plugins/PubObjectsExportPlugin.php index 2b9c40358c..83cf7fe2de 100644 --- a/classes/plugins/PubObjectsExportPlugin.php +++ b/classes/plugins/PubObjectsExportPlugin.php @@ -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(...)); @@ -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. * diff --git a/classes/scheduler/Scheduler.php b/classes/scheduler/Scheduler.php new file mode 100644 index 0000000000..57e6f55fcf --- /dev/null +++ b/classes/scheduler/Scheduler.php @@ -0,0 +1,36 @@ +schedule + ->call(fn () => (new UsageStatsLoader([]))->execute()) + ->daily() + ->name(UsageStatsLoader::class) + ->withoutOverlapping(); + } +} diff --git a/config.TEMPLATE.inc.php b/config.TEMPLATE.inc.php index ff1eb7431e..afec6b638c 100644 --- a/config.TEMPLATE.inc.php +++ b/config.TEMPLATE.inc.php @@ -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. @@ -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: +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 diff --git a/dbscripts/xml/install.xml b/dbscripts/xml/install.xml index 547212d81d..fdec64eaf7 100644 --- a/dbscripts/xml/install.xml +++ b/dbscripts/xml/install.xml @@ -33,7 +33,6 @@ - diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index 656da004aa..b3c14a8c22 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -110,6 +110,7 @@ + diff --git a/docs/release-notes/README-3.5.0 b/docs/release-notes/README-3.5.0 index de023b989c..7813ffc554 100644 --- a/docs/release-notes/README-3.5.0 +++ b/docs/release-notes/README-3.5.0 @@ -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 ------------ diff --git a/registry/scheduledTasks.xml b/registry/scheduledTasks.xml deleted file mode 100644 index e18867d54f..0000000000 --- a/registry/scheduledTasks.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - Send automated statistics reports to server managers and editors. - - - - Automatically remove unvalidated and expired users. - - - - Update the DB-IP city lite database periodically to ensure the geographical stats remain accurate. - - - - Process the usage stats logs and load the numbers into the DB tables. - - - - Process pending queue jobs in the default queue driver and queue - - - - Automatically remove jobs that failed more than X days ago. The time limit can be changed in the the delete_failed_jobs_after setting in the config file. - - - - Remove expired Invitations daily - - - diff --git a/tools/runScheduledTasks.php b/tools/runScheduledTasks.php deleted file mode 100644 index 9214085ebb..0000000000 --- a/tools/runScheduledTasks.php +++ /dev/null @@ -1,26 +0,0 @@ -execute(); From 8433c3dd7adfe7087400668de5ba5db25735897c Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 30 Jul 2024 15:07:50 +0600 Subject: [PATCH 2/5] pkp/pkp-lib#9678 Submodule Update ##touhidurabir/i9678_main## --- lib/pkp | 2 +- plugins/generic/acron | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pkp b/lib/pkp index 22af741d44..f391c7a8d1 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit 22af741d448e394dcbaeb8cc652530f5705666e1 +Subproject commit f391c7a8d1e570d64666beb3926258abed77a709 diff --git a/plugins/generic/acron b/plugins/generic/acron index cb707fdcb8..0757ad78ef 160000 --- a/plugins/generic/acron +++ b/plugins/generic/acron @@ -1 +1 @@ -Subproject commit cb707fdcb8ddb32fdbcfbc3cd4e74cd3e3b45431 +Subproject commit 0757ad78ef1d0bd0bc21ed2fcebd46418bbe58e6 From f7d7c64b6dff221781559b5622f058a244c93c01 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 30 Jul 2024 15:34:27 +0600 Subject: [PATCH 3/5] pkp/pkp-lib#9678 Submodule Update ##touhidurabir/i9678_main## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index f391c7a8d1..ffbaf19791 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit f391c7a8d1e570d64666beb3926258abed77a709 +Subproject commit ffbaf197915f7062ab15f93495cbe826f465309f From 0a8878870b7aebbb9d2f7d1fd237facb7304fe66 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 30 Jul 2024 18:23:40 +0600 Subject: [PATCH 4/5] pkp/pkp-lib#9678 Acron unlinked and removed --- .gitmodules | 3 --- plugins/generic/acron | 1 - 2 files changed, 4 deletions(-) delete mode 160000 plugins/generic/acron diff --git a/.gitmodules b/.gitmodules index 9aa44e4356..8ef316a72d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/plugins/generic/acron b/plugins/generic/acron deleted file mode 160000 index 0757ad78ef..0000000000 --- a/plugins/generic/acron +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0757ad78ef1d0bd0bc21ed2fcebd46418bbe58e6 From ae2f9e52798fcf3553a5834ba595691ab131bfc9 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Wed, 31 Jul 2024 16:18:36 +0600 Subject: [PATCH 5/5] pkp/pkp-lib#9678 Submodule Update ##touhidurabir/i9678_main## --- lib/pkp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pkp b/lib/pkp index ffbaf19791..96faf2ed58 160000 --- a/lib/pkp +++ b/lib/pkp @@ -1 +1 @@ -Subproject commit ffbaf197915f7062ab15f93495cbe826f465309f +Subproject commit 96faf2ed58329fad65baa62c2c088b5516fa9af5