Skip to content

Commit 968f2ed

Browse files
authored
Fixed notification daemon for different local/remote cromwell servers. (#96)
1 parent caec4d3 commit 968f2ed

File tree

1 file changed

+35
-8
lines changed

1 file changed

+35
-8
lines changed

cromshell

+35-8
Original file line numberDiff line numberDiff line change
@@ -1386,21 +1386,31 @@ function notify()
13861386
[[ $? -ne 0 ]] && error "ERROR: Could not copy cromshell to server ${hostServer}" && error "$(cat ${tmpOut})" && exit 7
13871387

13881388
# Spin off notification process on the server:
1389-
results=$( ssh ${hostServer} "~/${SCRIPTNAME} notify ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL}" )
1389+
results=$( ssh ${hostServer} "~/${SCRIPTNAME} _rawNotify ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL}" )
13901390
[[ $? -ne 0 ]] && error "ERROR: Could not start notification daemon on ${hostServer}" && exit 8
13911391

13921392
# Let the user know we've done our job:
13931393
echo "Spun off thread on ${hostServer} - PID = $( echo "${results}" | grep "Spun off thread on PID" | sed 's#Spun off thread on PID ##g' )"
13941394
else
1395-
error "Spinning off notification to ${email} thread for"
1396-
error " workflow: ${WORKFLOW_ID}"
1397-
error " from Cromwell server: ${WORKFLOW_SERVER_URL}"
1398-
error "..."
1399-
nohup bash -c "source ${SCRIPTDIR}/${SCRIPTNAME}; _notifyHelper ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL}" &>/dev/null &
1400-
echo "Spun off thread on PID $!"
1395+
_rawNotify ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL}
14011396
fi
14021397
}
14031398

1399+
# Perform a raw notification without validating any input arguments.
1400+
function _rawNotify()
1401+
{
1402+
local WORKFLOW_ID=$1
1403+
local email=$2
1404+
local WORKFLOW_SERVER_URL=$3
1405+
1406+
error "Spinning off notification thread to ${email} for"
1407+
error " workflow: ${WORKFLOW_ID}"
1408+
error " from Cromwell server: ${WORKFLOW_SERVER_URL}"
1409+
error "..."
1410+
nohup bash -c "source ${SCRIPTDIR}/${SCRIPTNAME}; _notifyHelper ${WORKFLOW_ID} ${email} ${WORKFLOW_SERVER_URL}" &>/dev/null &
1411+
echo "Spun off thread on PID $!"
1412+
}
1413+
14041414
# Helper function for the notify command that actually notifies the user:
14051415
function _notifyHelper()
14061416
{
@@ -1706,6 +1716,10 @@ if ${ISINTERACTIVESHELL} ; then
17061716
cleanup|submit|status|logs|execution-status-count|metadata|slim-metadata|timing|abort|notify|list|fetch-all|fetch-logs|list-outputs)
17071717
# This is a good sub-command, so we do not need to do anything.
17081718
;;
1719+
_rawNotify)
1720+
# This is a valid internal sub-command.
1721+
# While it should never be called directly by the user, it is possible that this was called by another command in this script.
1722+
;;
17091723
*)
17101724
if [[ ${#SUB_COMMAND} -eq 0 ]]; then
17111725
simpleUsage
@@ -1722,14 +1736,27 @@ if ${ISINTERACTIVESHELL} ; then
17221736
r=$?
17231737
[[ ${r} -ne 0 ]] && exit 6
17241738

1739+
# Sanitize the displayed sub-command:
1740+
SUB_COMMAND_FOR_DISPLAY=${SUB_COMMAND}
1741+
case ${SUB_COMMAND} in
1742+
_rawNotify)
1743+
SUB_COMMAND_FOR_DISPLAY="notify"
1744+
;;
1745+
esac
1746+
17251747
# Handle specific sub-command args and and call our sub-command:
1726-
error "Sub-Command: ${SUB_COMMAND}"
1748+
error "Sub-Command: ${SUB_COMMAND_FOR_DISPLAY}"
17271749
case ${SUB_COMMAND} in
17281750
# These are the sub-commands that take arguments other than workflow IDs:
17291751
cleanup|submit|list|notify|execution-status-count)
17301752
${SUB_COMMAND} $@
17311753
rv=$?
17321754
;;
1755+
# These are internal sub-commands that take arguments that should not be modified:
1756+
_rawNotify)
1757+
${SUB_COMMAND} $@
1758+
rv=$?
1759+
;;
17331760
# Handle sub-commands that only take workflow IDs:
17341761
*)
17351762
extract_workflow_ids_from_args $@

0 commit comments

Comments
 (0)