Merge pull request #88 from opencultureconsulting:felixlohmeier/import-tmpdir-is-86
fix tmpdir trap
This commit is contained in:
commit
1a8fcda377
24
orcli
24
orcli
|
@ -698,7 +698,7 @@ function get_id() {
|
|||
# common import tasks to support multiple files and URLs
|
||||
# shellcheck shell=bash
|
||||
function init_import() {
|
||||
local files file tmpdir
|
||||
local files file
|
||||
# catch args, convert the space delimited string to an array
|
||||
files=()
|
||||
eval "files=(${args[file]})"
|
||||
|
@ -1051,6 +1051,11 @@ orcli_test_command() {
|
|||
error "OpenRefine's startup script (refine) not found!" "Did you put orcli in your OpenRefine app dir?"
|
||||
fi
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port 3333." "Please stop the other process."
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
@ -1065,17 +1070,12 @@ orcli_test_command() {
|
|||
unzip -q -j orcli.zip "*/tests/data/*" -d "tests/data/"
|
||||
fi
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port 3333." "Please stop the other process."
|
||||
fi
|
||||
|
||||
# start OpenRefine with tmp workspace
|
||||
$openrefine -d "$OPENREFINE_TMPDIR" -x refine.headless=true -v warn &>"$OPENREFINE_TMPDIR/openrefine.log" &
|
||||
OPENREFINE_PID="$!"
|
||||
|
||||
# update trap to kill OpenRefine on error or exit
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
|
||||
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
|
||||
|
@ -1294,21 +1294,21 @@ orcli_run_command() {
|
|||
error "OpenRefine's startup script (refine) not found!" "Did you put orcli in your OpenRefine app dir?"
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port ${args[--port]}." "Hint: Stop the other process or use another port."
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
||||
# start OpenRefine with tmp workspace and autosave period 25 hours
|
||||
REFINE_AUTOSAVE_PERIOD=1440 $openrefine -d "$OPENREFINE_TMPDIR" -m "${args[--memory]}" -p "${args[--port]}" -x refine.headless=true -v warn &>"$OPENREFINE_TMPDIR/openrefine.log" &
|
||||
OPENREFINE_PID="$!"
|
||||
|
||||
# update trap to kill OpenRefine on error or exit
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# common import tasks to support multiple files and URLs
|
||||
# shellcheck shell=bash
|
||||
function init_import() {
|
||||
local files file tmpdir
|
||||
local files file
|
||||
# catch args, convert the space delimited string to an array
|
||||
files=()
|
||||
eval "files=(${args[file]})"
|
||||
|
|
|
@ -38,21 +38,21 @@ else
|
|||
error "OpenRefine's startup script (refine) not found!" "Did you put orcli in your OpenRefine app dir?"
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port ${args[--port]}." "Hint: Stop the other process or use another port."
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
||||
# start OpenRefine with tmp workspace and autosave period 25 hours
|
||||
REFINE_AUTOSAVE_PERIOD=1440 $openrefine -d "$OPENREFINE_TMPDIR" -m "${args[--memory]}" -p "${args[--port]}" -x refine.headless=true -v warn &>"$OPENREFINE_TMPDIR/openrefine.log" &
|
||||
OPENREFINE_PID="$!"
|
||||
|
||||
# update trap to kill OpenRefine on error or exit
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
|
||||
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
|
||||
|
|
|
@ -8,6 +8,11 @@ else
|
|||
error "OpenRefine's startup script (refine) not found!" "Did you put orcli in your OpenRefine app dir?"
|
||||
fi
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port 3333." "Please stop the other process."
|
||||
fi
|
||||
|
||||
# create tmp directory
|
||||
OPENREFINE_TMPDIR="$(mktemp -d)"
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; }' 0 2 3 15
|
||||
|
@ -22,17 +27,12 @@ if ! [[ -f "tests/help.sh" ]]; then
|
|||
unzip -q -j orcli.zip "*/tests/data/*" -d "tests/data/"
|
||||
fi
|
||||
|
||||
# check if OpenRefine is already running
|
||||
if curl -fs "${OPENREFINE_URL}" &>/dev/null; then
|
||||
error "OpenRefine is already running on port 3333." "Please stop the other process."
|
||||
fi
|
||||
|
||||
# start OpenRefine with tmp workspace
|
||||
$openrefine -d "$OPENREFINE_TMPDIR" -x refine.headless=true -v warn &>"$OPENREFINE_TMPDIR/openrefine.log" &
|
||||
OPENREFINE_PID="$!"
|
||||
|
||||
# update trap to kill OpenRefine on error or exit
|
||||
trap '{ rm -rf "$OPENREFINE_TMPDIR"; kill -9 "$OPENREFINE_PID"; }' 0 2 3 15
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue