Skip to content

Commit 044d549

Browse files
authored
Curl timeouts (#54)
* Added in -t flag for adjusting CURL timeouts.
1 parent d615309 commit 044d549

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ requires `column`, `curl`, `mail`, and [jq](https://stedolan.github.io/jq/)
2626
```
2727
cromshell submit workflow.wdl inputs.json options.json dependencies.zip
2828
cromshell status
29+
cromshell -t 20 metadata
2930
cromshell logs -2
3031
```
3132

33+
### Supported Flags:
34+
* `-t` `TIMEOUT`
35+
* Set the curl connect timeout to `TIMEOUT` seconds.
36+
* Also sets the curl max timeout to `2*TIMEOUT` seconds.
37+
* `TIMEOUT` must be an integer.
38+
3239
### Supported Subcommands:
3340

3441

cromshell

+31-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ FOLDER_URL=$( echo ${CROMWELL_URL} | sed -e 's#ht.*://##g' )
5252
CROMWELL_METADATA_PARAMETERS="excludeKey=submittedFiles&expandSubWorkflows=true"
5353

5454
CURL_CONNECT_TIMEOUT=5
55-
CURL_MAX_TIMEOUT=10
55+
let CURL_MAX_TIMEOUT=2*${CURL_CONNECT_TIMEOUT}
5656

5757
PING_CMD='ping -c1 -W1 -w10'
5858
if [[ $( uname ) == "Darwin" ]] ; then
@@ -103,7 +103,7 @@ function simpleUsage()
103103
if [[ $# -ne 0 ]] ; then
104104
usage | grep " ${1} " | sed -e 's#\(.*]\).*#\1#g' -e "s#^[ \\t]*#Usage: ${SCRIPTNAME} #g"
105105
else
106-
echo -e "Usage: ${SCRIPTNAME} SUB-COMMAND [options]"
106+
echo -e "Usage: ${SCRIPTNAME} [-t TIMEOUT] SUB-COMMAND [options]"
107107
echo -e "Run and inspect workflows on a Cromwell server."
108108
fi
109109
}
@@ -121,8 +121,14 @@ function usage()
121121
echo -e " example usage:"
122122
echo -e " cromshell submit workflow.wdl inputs.json options.json dependencies.zip"
123123
echo -e " cromshell status"
124+
echo -e " cromshell -t 50 status"
124125
echo -e " cromshell logs -2"
125126
echo -e ""
127+
echo -e "Supported Flags:"
128+
echo -e " -t TIMEOUT Set the curl connect timeout to TIMEOUT seconds."
129+
echo -e " Also sets the curl max timeout to 2*TIMEOUT seconds."
130+
echo -e " TIMEOUT must be an integer."
131+
echo -e ""
126132
echo -e "Supported Subcommands:"
127133
echo -e ""
128134
echo -e " Start/Stop workflows:"
@@ -1372,6 +1378,29 @@ if ${ISINTERACTIVESHELL} ; then
13721378
# Check the remaining arguments for help and display it if we have to:
13731379
checkForComplexHelpArgument $@
13741380

1381+
# Get flags:
1382+
while getopts ":t:" opt ; do
1383+
case ${opt} in
1384+
t)
1385+
# Ensure that the value given to -t is numerical:
1386+
echo ${OPTARG} | grep -q -E '^[0-9]+$'
1387+
rv=$?
1388+
[ $rv -ne 0 ] && invalidSubCommand '' "flag value (${OPTARG})" "-${opt} argument must be an integer."
1389+
1390+
# Set our timeouts:
1391+
CURL_CONNECT_TIMEOUT=${OPTARG}
1392+
let CURL_MAX_TIMEOUT=2*${CURL_CONNECT_TIMEOUT}
1393+
;;
1394+
:)
1395+
invalidSubCommand '' 'flag value' "-${opt} requires an argument."
1396+
;;
1397+
*)
1398+
invalidSubCommand '' flag ${OPTARG}
1399+
;;
1400+
esac
1401+
done
1402+
shift $((OPTIND-1))
1403+
13751404
# Get our sub-command:
13761405
SUB_COMMAND=${1}
13771406
shift

0 commit comments

Comments
 (0)