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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cli/magento-2/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

EMAIL_RECIPIENT=""
MAX_DURATION="43200"
ERROR_REGEX="Fatal error"
ERROR_REGEX="(PHP Fatal error|PHP Parse error|main\.ERROR)"
ERROR_REGEX_MATCH_EXIT_CODE=1

##########################################
# Do not modify anything below this line #
Expand Down Expand Up @@ -46,8 +47,10 @@ echo "cd $REL_INSTALLDIR; $PHP_BIN update/cron.php" | timeout $MAX_DURATION fake
echo "cd $REL_INSTALLDIR; $PHP_BIN bin/magento setup:cron:run" | timeout $MAX_DURATION fakechroot /usr/sbin/chroot /microcloud/domains/$DOMAIN_GROUP /bin/bash >> $LOG_FILE 2>&1; [ $? -ne 0 ] && RES=$?

if [ $RES -eq 0 ] && [ -s "$LOG_FILE" ] && [[ ! -z "$ERROR_REGEX" ]]; then
grep -qE "${ERROR_REGEX}" $LOG_FILE
[ $? -ne 0 ] && RES=$?
ERROR_REGEX_MATCH_COUNT=$(grep -cE "${ERROR_REGEX}" $LOG_FILE)
if [ $ERROR_REGEX_MATCH_COUNT -ne 0 ]; then
RES=$ERROR_REGEX_MATCH_EXIT_CODE
fi
fi

if [ $RES -ne 0 ] && [[ ! -z "$EMAIL_RECIPIENT" ]]; then
Expand Down