Problem/Motivation
I thought I'd try the using the new drush maestro:orchestrate command in cron, to save a HTTP round trip each time.
But I had to use drush maestro:orchestrate --quiet to suppress the "[notice] Starting Maestro orchestrator..." and "[success] Maestro orchestrator finished." output. I figured that wouldn't be a problem.
However, then one of the custom tasks failed (threw an exception), and I didn't get an email notification from cron as I expected, so I didn't find out about it until a user reported it days later.
I found this is because the exception is caught in MaestroCommands::orchestrate() and turned into a logged error:
try {
// ...
}
catch (\Throwable $e) {
$this->logger()->error('Exception while running orchestrator: ' . $e->getMessage());
return 1;
}
This has two downsides:
1. The Drush --quiet flag suppresses error messages as well as success and notices :-( (but doesn't suppress exceptions).
2. There's no way to see the backtrace to track down the cause (normally -v will show it).
Steps to reproduce
- Make a Maestro batch function task that throws an exception
- Run
drush maestro:orchestrate --quiet
Proposed resolution
Remove the try/catch completely - Drush will handle it correctly (display the error and set the exit code to 1).
Comments
Comment #3
_randy commentedSure, I removed the try/catch and updated the parameter returns to use the Drush commands constants.
Let me know if that helps.
Comment #4
mi-dave commentedYes, that works perfectly, thanks!
(You might want to use the constants in
startProcess()too. :-))Comment #6
_randy commentedAh, indeed. Fixed as well. I'll close this issue down!