Merge pull request #96 from opencultureconsulting:felixlohmeier/workaround-for-curl-95

workaround for curl --retry-connrefused bug
This commit is contained in:
Felix Lohmeier 2022-12-13 11:08:41 +01:00 committed by GitHub
commit 748137e15a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 27 deletions

39
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
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
}

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
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

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
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