aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2018-11-23 11:21:51 +1100
committerJustin Bedo <cu@cua0.org>2018-11-23 11:36:08 +1100
commit09864bb48d3452f52c4ff4f971ac48989726d898 (patch)
tree07c8c1c8149b210999862b72a97fa2a9334114c6
parent0ade062d2da8a7111b14aa3d72ef7c741e98352d (diff)
qsub: be more specific with qstat polling
-rw-r--r--lib/qsub.nix14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/qsub.nix b/lib/qsub.nix
index f0b0660..12981f9 100644
--- a/lib/qsub.nix
+++ b/lib/qsub.nix
@@ -21,14 +21,14 @@
'';
qsub = writeScript "qsub" ''
- #!/bin/bash
+ #!${stdenv.shell}
PATH=/usr/bin:/bin:/usr/sbin:/sbin
SHELL=/bin/sh
NIX_BUILD_CORES=${toString ppn}
id=$(qsub -l nodes=1:ppn=${toString ppn},mem=${toString mem}gb,walltime=${walltime} -N "${name}" ${script})
function cleanup {
- qstat ''${id%%.} 2> /dev/null > /dev/null && qdel $id || true
+ qdel $id 2>/dev/null || true
sleep 5
rm -rf ${tmpDir}/$id
}
@@ -36,12 +36,16 @@
cp -r $TMPDIR ${tmpDir}/$id
set > ${tmpDir}/$id/nix-set
- while qstat ''${id%%.} 2> /dev/null > /dev/null ; do
- sleep 5
+ until qstat ''${id%%.} 2>&1 | grep "Unknown Job" > /dev/null ; do
+ sleep 60
done
cat ${tmpDir}/$id/qsub-stderr >&2
cat ${tmpDir}/$id/qsub-stdout
- exitCode=$(cat ${tmpDir}/$id/qsub-exit)
+ if [ -e ${tmpDir}/$id/qsub-exit ]; then
+ exitCode=$(cat ${tmpDir}/$id/qsub-exit)
+ else
+ exitCode=1
+ fi
exit $exitCode
'';