Skip to content

Commit

Permalink
Use separate group & process for cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-kl1 committed Nov 23, 2023
1 parent e4103df commit d20f403
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cron/CleanCron.php → Cron/Cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Magento\Framework\Exception\LocalizedException;
use Opengento\WebapiLogger\Model\Clean;

class CleanCron
class Cleaner
{
public function __construct(private Clean $clean) {}

Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ password
token
email</secret_words>
<clean_older_than_hours>24</clean_older_than_hours>
<clean_scheduler>0 * * * *</clean_scheduler>
</log>
</webapi_logs>
</default>
Expand Down
18 changes: 18 additions & 0 deletions etc/cron_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © OpenGento, All rights reserved.
* See LICENSE bundled with this library for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
<group id="opengento_webapi_logger">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>60</history_success_lifetime>
<history_failure_lifetime>600</history_failure_lifetime>
<use_separate_process>1</use_separate_process>
</group>
</config>
6 changes: 3 additions & 3 deletions etc/crontab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<group id="default">
<job name="webapilogs_clean" instance="Opengento\WebapiLogger\Cron\CleanCron" method="execute">
<schedule>0 * * * *</schedule>
<group id="opengento_webapi_logger">
<job name="opengento_webapi_logger_cleaner" instance="Opengento\WebapiLogger\Cron\Cleaner" method="execute">
<config_path>webapi_logs/log/clean_scheduler</config_path>
</job>
</group>
</config>

0 comments on commit d20f403

Please sign in to comment.