Commit 17a954e6 authored by ulrich_y's avatar ulrich_y
Browse files

Clean up udocker

parent fa11f653
......@@ -109,7 +109,14 @@ function list_descendants () {
}
function diegracefully () {
echo "Killing $$ (self) and all children"
kill `list_descendants $$`
if [ ! -f "/usr/bin/srun" ]; then
kill `list_descendants $$`
fi
if [ -n "$containerid" ]; then
echo "Removing docker container $containerid"
udocker unprotect $containerid
udocker rm $containerid
fi
exit
}
spid=1
......@@ -125,6 +132,7 @@ function wakeup () {
if [ -f "/usr/bin/srun" ]; then
echo "This is a merlin system"
maxjobs=100000
trap 'diegracefully' TERM
else
set -m
export SLURM_JOB_ID=`date +%s`
......@@ -241,7 +249,7 @@ do
image)
img=$1
echo "Using Docker image $img"
containerid=$(udocker create $img)
export containerid=$(udocker create $img)
echo "Created container $containerid"
udocker protect $containerid
if [ -n "$2" ]; then
......@@ -288,3 +296,10 @@ until wait ; do : ; done
}
echo "[`date`] All jobs returned"
trap - EXIT
trap - SIGCHLD
if [ -n "$containerid" ]; then
udocker ps
udocker unprotect $containerid
udocker rm $containerid
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment