Skip to content

Instantly share code, notes, and snippets.

@AlexisDucastel
Created May 30, 2024 09:02
Show Gist options
  • Save AlexisDucastel/0e92c8119496184a5291c14f30f40a81 to your computer and use it in GitHub Desktop.
Save AlexisDucastel/0e92c8119496184a5291c14f30f40a81 to your computer and use it in GitHub Desktop.
Front-Commerce backend check
pingBackend() {
BACKEND_NAME="$1"
BACKEND_URL="$2"
DETAIL=$(curl -sL -o /dev/null -w "code=%{response_code} time=%{time_total} error=%{errormsg}\n" "$BACKEND_URL")
if [ $? -eq 0 ]; then
RES=" OK "
else
RES="FAIL"
fi
echo "[${RES}][$BACKEND_NAME] $DETAIL"
}
if grep -q 'server/modules/magento2' .front-commerce.js; then
pingBackend M2 "${FRONT_COMMERCE_MAGENTO_ENDPOINT}/rest/V1/frontcommerce/urls/match?urls[]=/test"
fi
if grep -q 'server/modules/magento1' .front-commerce.js; then
pingBackend M1 "${FRONT_COMMERCE_MAGENTO_ENDPOINT}/api/rest/frontcommerce/urls/match?urls\[0\]=/test"
fi
if [ ! -z "$FRONT_COMMERCE_ES_HOST" ]; then
pingBackend ES "$FRONT_COMMERCE_ES_HOST"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment