workaround for curl --retry-connrefused bug

This commit is contained in:
felixlohmeier 2022-12-13 10:08:25 +00:00
parent 87cb4d1a30
commit 1aafcd9a3f
3 changed files with 30 additions and 27 deletions

35
orcli
View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script was generated by bashly 0.9.0 (https://bashly.dannyb.co)
# This script was generated by bashly 0.9.1 (https://bashly.dannyb.co)
# Modifying it manually is not recommended
# :wrapper.bash3_bouncer
@ -1173,9 +1173,12 @@ orcli_test_command() {
# update trap to kill OpenRefine on error or exit
trap '{ rm -rf "$OPENREFINE_TMPDIR"; rm -rf /tmp/jetty-127_0_0_1-3333*; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
# wait until OpenRefine is running (timeout 20s)
if ! curl -fs --retry 20 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# wait until OpenRefine is running (timeout 15s + 15s)
if ! curl -fs --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# try again with IPv4 only
if ! curl -fs -4 --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
error "starting OpenRefine server failed!"
fi
else
log "started OpenRefine with tmp workspace ${OPENREFINE_TMPDIR}"
fi
@ -1406,9 +1409,12 @@ orcli_run_command() {
# update trap to kill OpenRefine on error or exit
trap '{ rm -rf "$OPENREFINE_TMPDIR"; rm -rf /tmp/jetty-127_0_0_1-${OPENREFINE_URL##*:}*; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
# wait until OpenRefine is running (timeout 20s)
if ! curl -fs --retry 20 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# wait until OpenRefine is running (timeout 15s + 15s)
if ! curl -fs --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# try again with IPv4 only
if ! curl -fs -4 --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
error "starting OpenRefine server failed!"
fi
else
log "started OpenRefine" "port: ${args[--port]}" "memory: ${args[--memory]}" "tmpdir: ${OPENREFINE_TMPDIR}" "pid: ${OPENREFINE_PID}"
fi
@ -1489,15 +1495,13 @@ parse_requirements() {
# :command.dependencies_filter
if ! command -v curl >/dev/null 2>&1; then
printf "missing dependency: curl\n" >&2
# shellcheck disable=SC2059
printf "https://curl.se\n" >&2
printf "%s\n" "https://curl.se" >&2
exit 1
fi
if ! command -v jq >/dev/null 2>&1; then
printf "missing dependency: jq\n" >&2
# shellcheck disable=SC2059
printf "https://github.com/stedolan/jq\n" >&2
printf "%s\n" "https://github.com/stedolan/jq" >&2
exit 1
fi
@ -1505,8 +1509,7 @@ parse_requirements() {
action=${1:-}
case $action in
-*)
;;
-*) ;;
completions)
action="completions"
@ -1736,8 +1739,7 @@ orcli_import_parse_requirements() {
action=${1:-}
case $action in
-*)
;;
-*) ;;
csv)
action="csv"
@ -2237,8 +2239,7 @@ orcli_export_parse_requirements() {
action=${1:-}
case $action in
-*)
;;
-*) ;;
tsv)
action="tsv"
@ -2609,10 +2610,6 @@ run() {
fi
;;
"root")
root_command
;;
esac
}

View File

@ -54,9 +54,12 @@ OPENREFINE_PID="$!"
# update trap to kill OpenRefine on error or exit
trap '{ rm -rf "$OPENREFINE_TMPDIR"; rm -rf /tmp/jetty-127_0_0_1-${OPENREFINE_URL##*:}*; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
# wait until OpenRefine is running (timeout 20s)
if ! curl -fs --retry 20 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# wait until OpenRefine is running (timeout 15s + 15s)
if ! curl -fs --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# try again with IPv4 only
if ! curl -fs -4 --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
error "starting OpenRefine server failed!"
fi
else
log "started OpenRefine" "port: ${args[--port]}" "memory: ${args[--memory]}" "tmpdir: ${OPENREFINE_TMPDIR}" "pid: ${OPENREFINE_PID}"
fi

View File

@ -34,9 +34,12 @@ OPENREFINE_PID="$!"
# update trap to kill OpenRefine on error or exit
trap '{ rm -rf "$OPENREFINE_TMPDIR"; rm -rf /tmp/jetty-127_0_0_1-3333*; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
# wait until OpenRefine is running (timeout 20s)
if ! curl -fs --retry 20 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# wait until OpenRefine is running (timeout 15s + 15s)
if ! curl -fs --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
# try again with IPv4 only
if ! curl -fs -4 --retry 15 --retry-connrefused --retry-delay 1 "${OPENREFINE_URL}/command/core/get-version" &>/dev/null; then
error "starting OpenRefine server failed!"
fi
else
log "started OpenRefine with tmp workspace ${OPENREFINE_TMPDIR}"
fi