From 1aafcd9a3fce827997524d2b211a4ac584a44a96 Mon Sep 17 00:00:00 2001 From: felixlohmeier Date: Tue, 13 Dec 2022 10:08:25 +0000 Subject: [PATCH] workaround for curl --retry-connrefused bug --- orcli | 39 ++++++++++++++++++--------------------- src/run_command.sh | 9 ++++++--- src/test_command.sh | 9 ++++++--- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/orcli b/orcli index 9273e1d..69b9116 100755 --- a/orcli +++ b/orcli @@ -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 - error "starting OpenRefine server failed!" + # 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 - error "starting OpenRefine server failed!" + # 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 } diff --git a/src/run_command.sh b/src/run_command.sh index 1747d89..0de0b4d 100644 --- a/src/run_command.sh +++ b/src/run_command.sh @@ -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 - error "starting OpenRefine server failed!" +# 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 diff --git a/src/test_command.sh b/src/test_command.sh index a06d8a2..5d24847 100644 --- a/src/test_command.sh +++ b/src/test_command.sh @@ -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 - error "starting OpenRefine server failed!" +# 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