Skip to content

Commit

Permalink
release v1.10, safe cleanup handler (2) issue #4
Browse files Browse the repository at this point in the history
  • Loading branch information
felixlohmeier committed Nov 7, 2017
1 parent 978344a commit 52fff42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions openrefine-batch-docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# openrefine-batch-docker.sh, Felix Lohmeier, v1.10, 2017-11-05
# openrefine-batch-docker.sh, Felix Lohmeier, v1.10, 2017-11-07
# https://github.com/felixlohmeier/openrefine-batch

# check system requirements
Expand Down Expand Up @@ -130,6 +130,7 @@ if [ -z "$outputdir" ]; then
fi
if [ "$(ls -A "$outputdir" 2>/dev/null)" ];then
echo 1>&2 "path to directory for exported files (and OpenRefine workspace) is not empty"
echo 1>&2 "$outputdir"
exit 1
fi
if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then
Expand Down Expand Up @@ -180,7 +181,6 @@ memoryload=()
# safe cleanup handler
cleanup()
{
echo ""
echo "cleanup..."
docker stop -t=5000 ${uuid}
docker rm ${uuid}
Expand All @@ -190,7 +190,7 @@ cleanup()
for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done
fi
}
trap cleanup EXIT
trap "cleanup;exit" SIGHUP SIGINT SIGQUIT SIGTERM

# launch server
checkpoints=${#checkpointdate[@]}
Expand Down Expand Up @@ -344,6 +344,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi
fi

# run cleanup function
cleanup
echo ""

# calculate and print checkpoints
echo "=== Statistics ==="
echo ""
Expand Down
10 changes: 7 additions & 3 deletions openrefine-batch.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# openrefine-batch.sh, Felix Lohmeier, v1.10, 2017-11-05
# openrefine-batch.sh, Felix Lohmeier, v1.10, 2017-11-07
# https://github.com/felixlohmeier/openrefine-batch

# declare download URLs for OpenRefine and OpenRefine client
Expand Down Expand Up @@ -155,6 +155,7 @@ if [ -z "$outputdir" ]; then
fi
if [ "$(ls -A "$outputdir" 2>/dev/null)" ];then
echo 1>&2 "path to directory for exported files (and OpenRefine workspace) is not empty"
echo 1>&2 "$outputdir"
exit 1
fi
if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then
Expand Down Expand Up @@ -203,7 +204,6 @@ memoryload=()
# safe cleanup handler
cleanup()
{
echo ""
echo "cleanup..."
kill ${pid}
wait
Expand All @@ -213,7 +213,7 @@ cleanup()
for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done
fi
}
trap cleanup EXIT
trap "cleanup;exit" SIGHUP SIGINT SIGQUIT SIGTERM

# launch server
checkpoints=${#checkpointdate[@]}
Expand Down Expand Up @@ -370,6 +370,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi
fi

# run cleanup function
cleanup
echo ""

# calculate and print checkpoints
echo "=== Statistics ==="
echo ""
Expand Down

0 comments on commit 52fff42

Please sign in to comment.