diff options
author | paulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com> | 2018-11-30 14:43:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-30 14:43:09 +0100 |
commit | e3f725a16f48d303ddbd8afed0bcdd50c923b33f (patch) | |
tree | 1a2be583a43a04a48aebf39ed72c546f2288dccc /files/clever-wait-deploy.sh | |
parent | 7778d938b98ee3086a00fc4c932f442d648d23ef (diff) | |
parent | 85d8706c5b0f5672025342f70117909177657ff1 (diff) | |
download | ansible-clever-e3f725a16f48d303ddbd8afed0bcdd50c923b33f.tar.gz ansible-clever-e3f725a16f48d303ddbd8afed0bcdd50c923b33f.tar.zst ansible-clever-e3f725a16f48d303ddbd8afed0bcdd50c923b33f.zip |
Merge pull request #24 from paulrbr-fl/revert-clever-cli-updatev1.11
Reverting upgrade of clever-tools CLI
Diffstat (limited to 'files/clever-wait-deploy.sh')
-rwxr-xr-x | files/clever-wait-deploy.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/files/clever-wait-deploy.sh b/files/clever-wait-deploy.sh new file mode 100755 index 0000000..e0bbcf1 --- /dev/null +++ b/files/clever-wait-deploy.sh | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/bin/bash -e | ||
2 | |||
3 | function deploying { | ||
4 | checkStatus "$1" "IN PROGRESS" | ||
5 | } | ||
6 | |||
7 | function deployed { | ||
8 | checkStatus "$1" "OK" | ||
9 | } | ||
10 | |||
11 | function inactive { | ||
12 | local commit="$1" | ||
13 | [[ "$(clever activity | grep "$commit" | grep "DEPLOY" | wc -l)" == "0" ]] | ||
14 | } | ||
15 | |||
16 | function checkStatus { | ||
17 | local commit="$1" | ||
18 | local status="$2" | ||
19 | [[ "$(clever activity | grep "$commit" | grep "${status}\s\+DEPLOY" | wc -l)" == "1" ]] | ||
20 | } | ||
21 | |||
22 | function check { | ||
23 | local timeout=600 # 10 minutes | ||
24 | local commit="$1" | ||
25 | local samplingTime=5 | ||
26 | |||
27 | echo "Waiting for deployment start..." | ||
28 | while inactive "$commit" -a $timeout -gt 0 | ||
29 | do | ||
30 | sleep $samplingTime | ||
31 | let "timeout-=$samplingTime" | ||
32 | done | ||
33 | |||
34 | # Wait for completion | ||
35 | echo "Deployment in progress..." | ||
36 | while deploying "$commit" -a $timeout -gt 0 | ||
37 | do | ||
38 | sleep $samplingTime | ||
39 | let "timeout-=$samplingTime" | ||
40 | done | ||
41 | |||
42 | if [ $samplingTime -eq 0 ] | ||
43 | then | ||
44 | echo "Timeout" | ||
45 | fi | ||
46 | |||
47 | deployed "$commit" | ||
48 | } | ||
49 | |||
50 | function getHeadRev { | ||
51 | local chdir="$1/.git" | ||
52 | |||
53 | git --git-dir="$chdir" rev-parse HEAD | ||
54 | } | ||
55 | |||
56 | check "$(getHeadRev "$@")" | ||