Skip to content

Commit 33f3936

Browse files
Merge pull request #44 from netlogix/fix/cron-monitoring-bool-flags
fix: Ignore boolean flags or args without explicit = sign in cron monitoring
2 parents fedaa1d + 6210694 commit 33f3936

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

Classes/Aspects/CronMonitorAspect.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ private function getCommandLineArguments(): array
7373

7474
$commandLineArguments = [];
7575
foreach ($commandLine as $rawCommandLineArgument) {
76-
if (strpos($rawCommandLineArgument, '-') !== 0) {
76+
if (!str_starts_with($rawCommandLineArgument, '-')) {
7777
continue; // Skip non-argument parts of the command line
7878
}
79+
if (!str_contains($rawCommandLineArgument, '=')) {
80+
continue; // Skip bool flags or args without explicit equal sign
81+
}
7982

8083
list ($name, $value) = explode('=', $rawCommandLineArgument, 2);
8184
$name = ltrim($name, '-');

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,14 @@ Add cron monitoring slug and schedule to your command parameters:
383383
> --cron-monitor-max-time=CRON-MONITOR-MAX-TIME if command should be monitored then pass cron monitor max execution time
384384
> --cron-monitor-check-margin=CRON-MONITOR-CHECK-MARGIN if command should be monitored then pass cron monitor check margin
385385

386+
**Note: The equal sign between a parameter name and value is mandatory!**
387+
386388
example usage in crontab
387389
```
388-
0 0 * * * user ./flow sentry:test --cron-monitor-slug=sentry_test_midnight --cron-monitor-schedule "0 0 * * *"
390+
0 0 * * * user ./flow sentry:test --cron-monitor-slug=sentry_test_midnight --cron-monitor-schedule="0 0 * * *"
389391
```
390392
391-
Optionally you can also set max run time and check margin (see https://docs.sentry.io/platforms/php/crons/)
393+
Optionally, you can also set max run time and check margin (see https://docs.sentry.io/platforms/php/crons/)
392394
```
393-
0 0 * * * user ./flow sentry:test --cron-monitor-slug=sentry_test_midnight --cron-monitor-schedule "0 0 * * *" --cron-monitor-max-time=5 --cron-monitor-check-margin=2
395+
0 0 * * * user ./flow sentry:test --cron-monitor-slug=sentry_test_midnight --cron-monitor-schedule="0 0 * * *" --cron-monitor-max-time=5 --cron-monitor-check-margin=2
394396
```

0 commit comments

Comments
 (0)