Skip to content

Commit 9d081cd

Browse files
authored
Merge pull request #6 from CakeDC/feature/cake5-improvements
Feature/cake5 improvements
2 parents 97adf6a + cd50827 commit 9d081cd

File tree

12 files changed

+572
-58
lines changed

12 files changed

+572
-58
lines changed

.gitattributes

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Define the line ending behavior of the different file extensions
2+
# Set default behavior, in case users don't have core.autocrlf set.
3+
* text text=auto eol=lf
4+
5+
.php diff=php
6+
7+
# Declare files that will always have CRLF line endings on checkout.
8+
*.bat eol=crlf
9+
10+
# Declare files that will always have LF line endings on checkout.
11+
*.pem eol=lf
12+
13+
# Denote all files that are truly binary and should not be modified.
14+
*.png binary
15+
*.jpg binary
16+
*.gif binary
17+
*.ico binary
18+
*.mo binary
19+
*.pdf binary
20+
*.phar binary
21+
*.woff binary
22+
*.woff2 binary
23+
*.ttf binary
24+
*.otf binary
25+
*.eot binary
26+
27+
# Remove files for archives generated using `git archive`
28+
.github export-ignore
29+
.phive export-ignore
30+
contrib export-ignore
31+
tests/test_app export-ignore
32+
tests/TestCase export-ignore
33+
34+
.editorconfig export-ignore
35+
.gitattributes export-ignore
36+
.gitignore export-ignore
37+
.mailmap export-ignore
38+
.stickler.yml export-ignore
39+
Makefile export-ignore
40+
phpcs.xml export-ignore
41+
phpstan.neon.dist export-ignore
42+
phpstan-baseline.neon export-ignore
43+
phpunit.xml.dist export-ignore
44+
psalm.xml export-ignore
45+
psalm-baseline.xml export-ignore

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.1.0] - 2024-12-10
9+
* added commands to purge queues and test queues
10+
* fixed test queue template path
11+
* changed `queue_monitor purge` to `queue-monitor purge-logs`
12+
* changed `queue_monitor notify` to `queue-monitor notify
13+
* changed default configuration of `purgeLogsOlderThanDays` to 7 days instead of 30
14+
15+
## [2.0.2] - 2024-12-09
16+
* ported fixes and enhancement from version 1.x
17+
* fixed handling `QueueMonitor.purgeLogsOlderThanDays` in Purge command
18+
* added `QueueMonitor.disabled` option
19+
* added support for disabling queue monitor commands
20+
* updated README.md
21+
* decreased log level when queue monitor is disabled
22+
* replaced saveOrFail with save
23+
24+
## [2.0.1] - 2024-05-14
25+
### Fixed
26+
- Removed TimestampBehavior from LogsTable to avoid problems when TimestampBehavior is overriden
27+
828
## [2.0] - 2024-04-17
929

1030
### Added

README.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Versions and branches
44
| CakePHP | CakeDC Queue Monitor Plugin | Tag | Notes |
55
|:-------:|:--------------------------------------------------------------------------:|:------------:|:-------|
6-
| ^5.0 | [2.0.0](https://github.com/CakeDC/cakephp-queue-monitor/tree/2.next-cake5) | 2.next-cake5 | stable |
6+
| ^5.0 | [2.1.0](https://github.com/CakeDC/cakephp-queue-monitor/tree/2.next-cake5) | 2.next-cake5 | stable |
77
| ^4.4 | [1.0.0](https://github.com/CakeDC/cakephp-queue-monitor/tree/1.next-cake4) | 1.next-cake4 | stable |
88

99
## Overview
@@ -26,28 +26,14 @@ composer require cakedc/queue-monitor
2626
```
2727

2828
## Configuration
29-
30-
Add QueueMonitorPlugin to your `Application::bootstrap`:
31-
```php
32-
use Cake\Http\BaseApplication;
33-
use CakeDC\QueueMonitor\QueueMonitorPlugin;
34-
35-
class Application extends BaseApplication
36-
{
37-
// ...
38-
39-
public function bootstrap(): void
40-
{
41-
parent::bootstrap();
42-
43-
$this->addPlugin(QueueMonitorPlugin::class);
44-
}
45-
46-
// ...
47-
}
48-
29+
Add QueueMonitorPlugin to your application by running command:
30+
```shell
31+
bin/cake plugin load CakeDC/QueueMonitor
32+
```
33+
Run the required migrations
34+
```shell
35+
bin/cake migrations migrate -p CakeDC/QueueMonitor
4936
```
50-
5137
Set up the QueueMonitor configuration in your `config/app_local.php`:
5238
```php
5339
// ...
@@ -58,28 +44,22 @@ Set up the QueueMonitor configuration in your `config/app_local.php`:
5844

5945
// mailer config, the default is `default` mailer, you can ommit
6046
// this setting if you use default value
61-
'mailerConfig' => 'myCustomMailer',
47+
'mailerConfig' => 'default',
6248

63-
// the default is 30 minutes, you can ommit this setting if you
64-
// use the default value
65-
'longJobInMinutes' => 45,
49+
// the default is 30 minutes, you can ommit this setting if you use the default value
50+
'longJobInMinutes' => 30,
6651

67-
// the default is 30 days, you can ommit this setting if you
52+
// the default is 7 days, you can ommit this setting if you use the default value
6853
// its advised to set this value correctly after queue usage analysis to avoid
6954
// high space usage in db
70-
'purgeLogsOlderThanDays' => 10,
55+
'purgeLogsOlderThanDays' => 7,
7156

7257
// comma separated list of recipients of notification about long running queue jobs
7358
'notificationRecipients' => 'recipient1@yourdomain.com,recipient2@yourdomain.com,recipient3@yourdomain.com',
7459
],
7560
// ...
7661
```
7762

78-
Run the required migrations
79-
```shell
80-
bin/cake migrations migrate -p CakeDC/QueueMonitor
81-
```
82-
8363
For each queue configuration add `listener` setting
8464
```php
8565
// ...
@@ -95,19 +75,46 @@ For each queue configuration add `listener` setting
9575

9676
## Notification command
9777

98-
To set up notifications when there are long running or possible stuck jobs please use command
78+
To set up notifications when there are jobs running for a long time or jobs that may be stuck and blocking the queue
79+
please use command:
9980
```shell
100-
bin/cake queue_monitor notify
81+
bin/cake queue-monitor notify
10182
```
10283

10384
This command will send notification emails to recipients specified in `QueueMonitor.notificationRecipients`. Best is
104-
to use it as a cronjob
85+
to use it as a cronjob.
86+
87+
## Test Enqueue command
88+
89+
To quickly test if all queues are running correctly please run this command (replace `your-email@domain.com` with working
90+
email address:
91+
```shell
92+
bin/cake queue-monitor test-enqueue your-email@domain.com
93+
```
94+
95+
This command will send the command through all configured queues.
96+
97+
## Purge queues command
98+
To purge the content of a specified queue you can use the purge queue command:
99+
```shell
100+
bin/cake queue-monitor purge-queue your-queue-name
101+
102+
```
103+
104+
The above command will remove all pending queue jobs from the specified queue.
105+
106+
To purge all queues you can use command:
107+
108+
```shell
109+
bin/cake queue-monitor purge-queue --all
110+
111+
```
105112

106-
## Purge command
113+
## Purge Logs command
107114

108115
The logs table may grow overtime, to keep it slim you can use the purge command:
109116
```shell
110-
bin/cake queue_monitor purge
117+
bin/cake queue-monitor purge-logs
111118
```
112119

113120
This command will purge logs older than value specified in `QueueMonitor.purgeLogsOlderThanDays`, the value is in

src/Command/NotifyCommand.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ public function __construct(
4848
*/
4949
public static function defaultName(): string
5050
{
51-
return 'queue_monitor notify';
51+
return 'queue-monitor notify';
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public static function getDescription(): string
58+
{
59+
return __('Queue Monitoring notifier');
5260
}
5361

5462
/**
@@ -57,7 +65,7 @@ public static function defaultName(): string
5765
public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
5866
{
5967
return parent::buildOptionParser($parser)
60-
->setDescription(__('Queue Monitoring notifier'));
68+
->setDescription(self::getDescription());
6169
}
6270

6371
/**

src/Command/PurgeCommand.php renamed to src/Command/PurgeLogsCommand.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
use function Cake\I18n\__;
2626

2727
/**
28-
* Purge command.
28+
* Purge Logs command.
2929
*/
30-
final class PurgeCommand extends Command
30+
final class PurgeLogsCommand extends Command
3131
{
3232
use DisableTrait;
3333
use LogTrait;
3434

35-
private const DEFAULT_PURGE_DAYS_OLD = 30;
35+
private const DEFAULT_PURGE_DAYS_OLD = 7;
3636

3737
/**
3838
* Constructor
@@ -48,7 +48,15 @@ public function __construct(
4848
*/
4949
public static function defaultName(): string
5050
{
51-
return 'queue_monitor purge';
51+
return 'queue-monitor purge-logs';
52+
}
53+
54+
/**
55+
* @inheritDoc
56+
*/
57+
public static function getDescription(): string
58+
{
59+
return __('Queue Monitoring log purger');
5260
}
5361

5462
/**
@@ -57,7 +65,7 @@ public static function defaultName(): string
5765
public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
5866
{
5967
return parent::buildOptionParser($parser)
60-
->setDescription(__('Queue Monitoring log purger'));
68+
->setDescription(self::getDescription());
6169
}
6270

6371
/**
@@ -73,6 +81,7 @@ public function execute(Arguments $args, ConsoleIo $io)
7381

7482
return self::CODE_SUCCESS;
7583
}
84+
7685
$purgeLogsOlderThanDays = (int)Configure::read(
7786
'QueueMonitor.purgeLogsOlderThanDays',
7887
self::DEFAULT_PURGE_DAYS_OLD

0 commit comments

Comments
 (0)