Skip to content

Instantly share code, notes, and snippets.

@Darksecond
Created May 20, 2015 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darksecond/91b6ac328af43f521746 to your computer and use it in GitHub Desktop.
Save Darksecond/91b6ac328af43f521746 to your computer and use it in GitHub Desktop.
phantomjs
BIN=/usr/local/bin/phantomjs.bin
RET=1
MAX=5
RUN=0
until [ ${RET} -eq 0 ]; do
${BIN} $@
RET=$?
RUN=$(($RUN +1))
# exit immediately after max crashes
if [ ${RUN} -eq ${MAX} ]; then
echo "got ${RUN} unexpected results from phantomjs, giving up ..."
exit ${RET}
fi
# allowed values are 0-5
# see https://github.com/CoreMedia/jangaroo-tools/blob/master/jangaroo-maven/jangaroo-maven-plugin/src/main/resources/net/jangaroo/jooc/mvnplugin/phantomjs-joounit-page-runner.js
if [ ${RET} -lt 5 ]; then
if [ ${RET} -eq 1 ]; then
echo "phantomjs misconfigured or crashed, retrying ..."
else
exit ${RET}
fi
else
echo "got unexpected return value from phantomjs: ${RET}. Retrying ..."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment