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
# 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
@ -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
@ -180,7 +181,6 @@ memoryload=()
# safe cleanup handler
cleanup()
{
echo ""
echo "cleanup..."
docker stop -t=5000 ${uuid}
docker rm ${uuid}
@ -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[@]}
@ -344,6 +344,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi
fi
# run cleanup function
cleanup
echo ""
# calculate and print checkpoints
echo "=== Statistics ==="
echo ""

View File

@ -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
@ -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
@ -203,7 +204,6 @@ memoryload=()
# safe cleanup handler
cleanup()
{
echo ""
echo "cleanup..."
kill ${pid}
wait
@ -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[@]}
@ -370,6 +370,10 @@ if [ -n "$jsonfiles" ] || [ "$export" = "true" ]; then
fi
fi
# run cleanup function
cleanup
echo ""
# calculate and print checkpoints
echo "=== Statistics ==="
echo ""