-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
764f58c
commit 88af2ab
Showing
2 changed files
with
91 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,50 @@ | ||
#!/bin/bash | ||
|
||
pslot=$1 | ||
TASK_NAME=$2 | ||
CYCLE=$3 | ||
CYCLE=$2 | ||
shift | ||
shift | ||
TASK_NAMES=("$@") | ||
|
||
task_args=$(printf " -t %s" "${TASK_NAMES[@]}") | ||
num_tasks=${#TASK_NAMES[@]} | ||
|
||
# Define the workflow XML and database files | ||
WORKFLOW_XML=${pslot}/EXPDIR/${pslot}/${pslot}.xml | ||
WORKFLOW_DB=${pslot}/EXPDIR/${pslot}/${pslot}.db | ||
|
||
# Boot the task | ||
echo "booting $TASK_NAME for cycle $CYCLE" | ||
echo "booting ${TASK_NAMES[@]} for cycle $CYCLE" | ||
if [[ ! -e "$WORKFLOW_DB" ]]; then | ||
rocotorun -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" -t "$TASK_NAME" -c "$CYCLE" | ||
rocotorun -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" "$task_args" -c "$CYCLE" | ||
fi | ||
rocotoboot -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" -t "$TASK_NAME" -c "$CYCLE" | ||
rocotoboot -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" "$task_args" -c "$CYCLE" | ||
|
||
while true; do | ||
# Update the status of the task | ||
rocotorun -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" -t "$TASK_NAME" -c "$CYCLE" | ||
rocotorun -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" "$task_args" -c "$CYCLE" | ||
|
||
# Check the task status | ||
OUTPUT=$(rocotostat -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" -t "$TASK_NAME" -c "$CYCLE") | ||
STATUS=$(echo "$OUTPUT" | awk '$2 == task {print $4}' task="$TASK_NAME") | ||
num_succeeded=0 | ||
for task in "${TASK_NAMES[@]}"; do | ||
# Check the task status | ||
OUTPUT=$(rocotostat -w "$WORKFLOW_XML" -d "$WORKFLOW_DB" -t "$task" -c "$CYCLE") | ||
STATUS=$(echo "$OUTPUT" | awk '$2 == task {print $4}' task="$task") | ||
|
||
if [[ "$STATUS" == "SUCCEEDED" ]]; then | ||
echo "The task succeeded." | ||
if [[ "$STATUS" == "SUCCEEDED" ]]; then | ||
echo "$task succeeded." | ||
num_succeeded=$((num_succeeded + 1)) | ||
elif [[ "$STATUS" == "FAILED" ]]; then | ||
echo "$task failed." | ||
exit 1 | ||
elif [[ "$STATUS" == "DEAD" ]]; then | ||
echo "$task is dead." | ||
exit 1 | ||
else | ||
echo "$task is in state: $STATUS" | ||
fi | ||
done | ||
if [[ "$num_succeeded" == "$num_tasks" ]]; then | ||
exit 0 | ||
elif [[ "$STATUS" == "FAILED" ]]; then | ||
echo "The task failed." | ||
exit 1 | ||
elif [[ "$STATUS" == "DEAD" ]]; then | ||
echo "The task is dead." | ||
exit 1 | ||
else | ||
echo "The task is in state: $STATUS" | ||
fi | ||
sleep 10 | ||
done |