release v1.10, safe cleanup handler (2) issue #4

This commit is contained in:
Felix Lohmeier 2017-11-07 21:24:14 +01:00
parent 978344a55c
commit 52fff4281b
2 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/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 # https://github.com/felixlohmeier/openrefine-batch
# check system requirements # check system requirements
@ -130,6 +130,7 @@ if [ -z "$outputdir" ]; then
fi fi
if [ "$(ls -A "$outputdir" 2>/dev/null)" ];then 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 "path to directory for exported files (and OpenRefine workspace) is not empty"
echo 1>&2 "$outputdir"
exit 1 exit 1
fi fi
if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then
@ -180,7 +181,6 @@ memoryload=()
# safe cleanup handler # safe cleanup handler
cleanup() cleanup()
{ {
echo ""
echo "cleanup..." echo "cleanup..."
docker stop -t=5000 ${uuid} docker stop -t=5000 ${uuid}
docker rm ${uuid} docker rm ${uuid}
@ -190,7 +190,7 @@ cleanup()
for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done
fi fi
} }
trap cleanup EXIT trap "cleanup;exit" SIGHUP SIGINT SIGQUIT SIGTERM
# launch server # launch server
checkpoints=${#checkpointdate[@]} checkpoints=${#checkpointdate[@]}
@ -344,6 +344,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi fi
fi fi
# run cleanup function
cleanup
echo ""
# calculate and print checkpoints # calculate and print checkpoints
echo "=== Statistics ===" echo "=== Statistics ==="
echo "" echo ""

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/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 # https://github.com/felixlohmeier/openrefine-batch
# declare download URLs for OpenRefine and OpenRefine client # declare download URLs for OpenRefine and OpenRefine client
@ -155,6 +155,7 @@ if [ -z "$outputdir" ]; then
fi fi
if [ "$(ls -A "$outputdir" 2>/dev/null)" ];then 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 "path to directory for exported files (and OpenRefine workspace) is not empty"
echo 1>&2 "$outputdir"
exit 1 exit 1
fi fi
if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then if [ "$format" = "xml" ] || [ "$format" = "json" ] && [ -z "$inputoptions" ]; then
@ -203,7 +204,6 @@ memoryload=()
# safe cleanup handler # safe cleanup handler
cleanup() cleanup()
{ {
echo ""
echo "cleanup..." echo "cleanup..."
kill ${pid} kill ${pid}
wait wait
@ -213,7 +213,7 @@ cleanup()
for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done for i in "${crossprojects[@]}" ; do rm -r -f "${outputdir}/${i}" ; done
fi fi
} }
trap cleanup EXIT trap "cleanup;exit" SIGHUP SIGINT SIGQUIT SIGTERM
# launch server # launch server
checkpoints=${#checkpointdate[@]} checkpoints=${#checkpointdate[@]}
@ -370,6 +370,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi fi
fi fi
# run cleanup function
cleanup
echo ""
# calculate and print checkpoints # calculate and print checkpoints
echo "=== Statistics ===" echo "=== Statistics ==="
echo "" echo ""