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

Match indicating failure returns as success #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jameswithers
Copy link
Contributor

The -q flag at

grep -qE "${ERROR_REGEX}" $LOG_FILE
means grep returns 0 if a match is found (http://man7.org/linux/man-pages/man1/grep.1.html).

This appears to then be set as the result at

[ $? -ne 0 ] && RES=$?
when a result of zero is deemed a success (which it isn't in this case, as grep has found matches).

This proposed change better reflects the desired logic here: even if a command e.g. the one at

echo "cd $REL_INSTALLDIR; $PHP_BIN bin/magento cron:run" | timeout $MAX_DURATION fakechroot /usr/sbin/chroot /microcloud/domains/$DOMAIN_GROUP /bin/bash >> $LOG_FILE 2>&1; [ $? -ne 0 ] && RES=$?
successfully exits, it may still have logged an error, and this error (if found via a regex) needs to exit the cron wrapper itself with a value indicating failure (as well as sending an email)

The `-q` flag at https://github.com/sonassi/magestack-scripts/blob/509b84678eb7953caa7dfb60398bd1ab29852bd6/cli/magento-2/cron.sh#L49  means grep returns 0 if a match is found (http://man7.org/linux/man-pages/man1/grep.1.html).

This appears to then be set as the result at https://github.com/sonassi/magestack-scripts/blob/509b84678eb7953caa7dfb60398bd1ab29852bd6/cli/magento-2/cron.sh#L50, when a result of zero is deemed a success (which it isn't in this case, as grep has found matches).

This proposed change better reflects the desired logic here: even if a command (e.g. the one at https://github.com/sonassi/magestack-scripts/blob/509b84678eb7953caa7dfb60398bd1ab29852bd6/cli/magento-2/cron.sh#L44) successfully exits, it may still have logged an error, and this error (if found via a regex) needs to exit the cron wrapper itself with a value indicating failure (as well as sending an email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant