@@ -455,6 +455,8 @@ function assertCanCommunicateWithServer
455
455
curl -s ${1} /api/workflows/v1/backends > ${f}
456
456
grep -q ' supportedBackends' ${f}
457
457
r=$?
458
+ # Do some cleanup here for daemon processes.
459
+ rm -f ${f}
458
460
if [[ ${r} -ne 0 ]] ; then
459
461
turtleDead
460
462
error " Error: Cannot communicate with Cromwell server: ${serverName} "
@@ -524,8 +526,8 @@ function alias_workflow()
524
526
function populateWorkflowIdAndServerFromAlias()
525
527
{
526
528
local alias_name=${1}
527
- WORKFLOW_ID=$( awk " BEGIN{FS=\" \t\" }{if (\$ 6 == \" ${alias_name} \" ) {print}}" ${CROMWELL_SUBMISSIONS_FILE} | head -n1 | awk ' {print $3}' )
528
- WORKFLOW_SERVER_URL=$( awk " BEGIN{FS=\" \t\" }{if (\$ 6 == \" ${alias_name} \" ) {print}}" ${CROMWELL_SUBMISSIONS_FILE} | head -n1 | awk ' {print $2}' )
529
+ WORKFLOW_ID=$( awk " BEGIN{FS=\" \t\" }{if (\$ 6 == \" ${alias_name} \" ) {print}}" ${CROMWELL_SUBMISSIONS_FILE} | head -n1 | awk ' {print $3}' )
530
+ WORKFLOW_SERVER_URL=$( awk " BEGIN{FS=\" \t\" }{if (\$ 6 == \" ${alias_name} \" ) {print}}" ${CROMWELL_SUBMISSIONS_FILE} | head -n1 | awk ' {print $2}' )
529
531
530
532
if [[ -z ${WORKFLOW_ID} ]]; then
531
533
error " Invalid workflow/alias: ${alias_name} "
@@ -552,6 +554,9 @@ function populateWorkflowIdAndServerUrl()
552
554
grep ${WORKFLOW_ID} ${CROMWELL_SUBMISSIONS_FILE} > ${tmpFile}
553
555
r=$?
554
556
[[ ${r} -eq 0 ]] && WORKFLOW_SERVER_URL=$( awk ' {print $2}' ${tmpFile} )
557
+
558
+ # Do some cleanup here for daemon processes.
559
+ rm -f ${tmpFile}
555
560
else
556
561
if [[ -n " $userSpecifiedId " ]]; then
557
562
populateWorkflowIdAndServerFromAlias ${userSpecifiedId}
@@ -788,7 +793,7 @@ function submit()
788
793
789
794
assertCanCommunicateWithServer ${CROMWELL_URL}
790
795
791
- echo " Submitting job to server: ${CROMWELL_URL} "
796
+ echo " Submitting job to server: ${CROMWELL_URL} "
792
797
793
798
local response=$( curl -s -F workflowSource=@${wdl} ${2: + -F workflowInputs=@ ${json} } ${3: + -F workflowOptions=@ ${optionsJson} } ${4: + -F workflowDependencies=@ ${dependenciesZip} } ${CROMWELL_URL} /api/workflows/v1)
794
799
r=$?
@@ -848,7 +853,7 @@ function status()
848
853
assertCanCommunicateWithServer ${2}
849
854
local f=$( makeTemp )
850
855
curl -s ${2} /api/workflows/v1/${1} /status > ${f}
851
- [[ $? -ne 0 ]] && error " Could not connect to Cromwell server." && return 2
856
+ [[ $? -ne 0 ]] && error " Could not connect to Cromwell server." && rm -f ${f} && return 2
852
857
853
858
grep -qE ' "Failed"|"Aborted"|"fail"' ${f}
854
859
r=$?
@@ -900,6 +905,9 @@ function status()
900
905
awk " BEGIN { FS=OFS=\" \t\" } { if ((\$ 3 == \" ${1} \" ) && (\$ 2 == \" ${2} \" )) { \$ 5=\" ${workflowStatus} \" ; }; print }" ${CROMWELL_SUBMISSIONS_FILE} .bak > ${CROMWELL_SUBMISSIONS_FILE}
901
906
# sed -i .bak -e "s#\\(.*${1}.*\\.wdl\\)\\t*.*#\\1$(printf '\t')${workflowStatus}#g" ${CROMWELL_SUBMISSIONS_FILE}
902
907
908
+ # Do some cleanup here for daemons:
909
+ rm -f ${f} ${tmpExecutionStatusCount} ${tmpMetadata}
910
+
903
911
return ${retVal}
904
912
}
905
913
@@ -1009,6 +1017,9 @@ function execution-status-count()
1009
1017
jq ' .. | .calls? | values | map_values(group_by(.executionStatus) | map({(.[0].executionStatus): . | length}) | add)' " ${tempFile} "
1010
1018
checkPipeStatus " Could not read tmp file JSON data." " Could not parse JSON output from cromwell server."
1011
1019
fi
1020
+
1021
+ # Do some cleanup here for daemon processes.
1022
+ rm -f ${tempFile}
1012
1023
done
1013
1024
}
1014
1025
@@ -1085,6 +1096,8 @@ function printTaskStatus()
1085
1096
failedShards=$( tr ' \n' ' ' < ${tmpFailedShardsFile} | sed -E ' s/\[( )+//' | sed -E ' s/( )+\]//' )
1086
1097
echo -e " ${taskStatus}${indent} \tFailed shards: ${failedShards}${COLOR_NORM} "
1087
1098
fi
1099
+
1100
+ rm -f ${tmpFailedShardsFile} ${tmpStatusesFile}
1088
1101
}
1089
1102
1090
1103
# Bring up a browser window to view timing information on the job.
@@ -1530,7 +1543,8 @@ function notify()
1530
1543
# Send the script to the server:
1531
1544
local tmpOut=$( makeTemp )
1532
1545
scp ${SCRIPTDIR} /${SCRIPTNAME} ${hostServer} :~ /. & > ${tmpOut}
1533
- [[ $? -ne 0 ]] && error " ERROR: Could not copy cromshell to server ${hostServer} " && error " $( cat ${tmpOut} ) " && exit 7
1546
+ [[ $? -ne 0 ]] && error " ERROR: Could not copy cromshell to server ${hostServer} " && error " $( cat ${tmpOut} ) " && rm -f ${tmpOut} && exit 7
1547
+ rm -f ${tmpOut}
1534
1548
1535
1549
# Spin off notification process on the server:
1536
1550
results=$( ssh ${hostServer} " ~/${SCRIPTNAME} _rawNotify ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL} " )
@@ -1583,6 +1597,11 @@ function _notifyHelper()
1583
1597
echo -e " CROMWELL Task ${completionStatus} :\n\n${id} \n\non\n\n${cromwellServer} \n\n${separator} \n\nStatus:\n$( cat ${statusFile} ) \n\n${separator} \nMetadata:\n${metaData} \n\n${separator} \nSent by $( whoami ) @$( hostname ) on $( date ) \n\n\n" | mail -n -s " Cromwell Task ${completionStatus} [${cromwellServer} ] ${workflowFile} " ${email}
1584
1598
break
1585
1599
fi
1600
+ # Clean the temporary file just in case.
1601
+ # This might need to happen because of how this helper gets called.
1602
+ # Not sure the trap is working properly (i.e. it doesn't seem to be calling at_exit).
1603
+ rm -f ${statusFile}
1604
+
1586
1605
# wait for 10 seconds:
1587
1606
sleep 10
1588
1607
done
@@ -1900,8 +1919,8 @@ if ${ISINTERACTIVESHELL} ; then
1900
1919
esac
1901
1920
1902
1921
# Don't check JQ version if we're notifying.
1903
- # Why do this, you might ask?
1904
- # Because it's easier to hack our code than to get Broad IT to update software on our servers.
1922
+ # Why do this, you might ask?
1923
+ # Because it's easier to hack our code than to get Broad IT to update software on our servers.
1905
1924
if [[ " ${SUB_COMMAND_FOR_DISPLAY} " != " notify" ]] ; then
1906
1925
checkJQVersion
1907
1926
r=$?
0 commit comments