Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drush cron is sometimes missing info log output "Cron run completed" #6021

Open
klausi opened this issue Jun 3, 2024 · 0 comments
Open

drush cron is sometimes missing info log output "Cron run completed" #6021

klausi opened this issue Jun 3, 2024 · 0 comments

Comments

@klausi
Copy link
Contributor

klausi commented Jun 3, 2024

Describe the bug
We run Drupal cron with drush to catch errors. When the sentence "Cron run completed" is no in the output then we know it is an error

#!/bin/bash

# Only print drush output when it does not contain "Cron run completed."
# Usage: drush-cron9.sh /var/www/jobiqo-decoupled/backend

cd "$1" || exit
DRUSH_OUTPUT=$(/usr/bin/drush cron -v 2>&1)
RETURN_CODE=$?
# Check if the success message has a translation.
# Use it as regex pattern for grep.
SUCCESS_MESSAGE=$(/usr/bin/drush ev 'print t("Cron run successful.") . "|Cron run completed.";')
# If the success message is not in the output then we print all the output.
# shellcheck disable=SC2086
if echo $DRUSH_OUTPUT | grep -vqE "$SUCCESS_MESSAGE"; then
  echo "$DRUSH_OUTPUT"
fi
exit $RETURN_CODE

This worked fine in Drush 11, but since the upgrade to Drush 12.5.2 the cron command does not always print all info log messages. Somehow Drush or the Drupal site can get into a state where all info log messages are not printed in Drush output. A drush cr fixes it and then the output is correct again with all info log messages.

A broken drush cron -v output look like this, note the missing info messages at the end:

 [info] Drush bootstrap phase: bootstrapDrupalRoot()
 [info] Change working directory to /var/www/example/site/backend/web
 [info] Initialized Drupal 10.1.8 root directory at /var/www/example/site/backend/web
 [info] Drush bootstrap phase: bootstrapDrupalSite()
 [info] Initialized Drupal site example.com at sites/default
 [info] Drush bootstrap phase: bootstrapDrupalConfiguration()
 [info] Drush bootstrap phase: bootstrapDrupalDatabase()
 [info] Successfully connected to the Drupal database.
 [info] Drush bootstrap phase: bootstrapDrupalFull()
 [info] Starting bootstrap to none
 [info] Drush bootstrap phase 0
 [info] Try to validate bootstrap phase 0

Correct would be:

 [info] Drush bootstrap phase: bootstrapDrupalRoot()
 [info] Change working directory to /var/www/example/site/backend/web
 [info] Initialized Drupal 10.1.8 root directory at /var/www/example/site/backend/web
 [info] Drush bootstrap phase: bootstrapDrupalSite()
 [info] Initialized Drupal site example.com at sites/default
 [info] Drush bootstrap phase: bootstrapDrupalConfiguration()
 [info] Drush bootstrap phase: bootstrapDrupalDatabase()
 [info] Successfully connected to the Drupal database.
 [info] Drush bootstrap phase: bootstrapDrupalFull()
 [info] Starting bootstrap to none
 [info] Drush bootstrap phase 0
 [info] Try to validate bootstrap phase 0
 [info] Starting execution of commerce_cart_cron(), execution of example_mails_cron() took 14.49ms.
 [info] Starting execution of dblog_cron(), execution of commerce_cart_cron() took 9.02ms.
...
 [info] Execution of password_policy_cron() took 0.44ms.
 [info] Cron run completed.

To Reproduce
Unclear yet, we don't know how Drush/Drupal gets into the state that info log output is missing.

Expected behavior
Info log output is always printed including "Cron run completed".

Actual behavior
Info log output is missing from drush cron output.

Workaround
?

System Configuration

Q A
Drush version? 12.5.2
Drupal version? 10.1.8
PHP version 8.1
OS? Linux

Additional information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants