You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while [ -h"$SOURCE" ];do# resolve $SOURCE until the file is no longer a symlink
14
-
DIR="$(cd -P "$( dirname "$SOURCE")"&&pwd)"
15
-
SOURCE="$(readlink "$SOURCE")"
16
-
[[ $SOURCE!= /* ]] && SOURCE="$DIR/$SOURCE"# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
14
+
DIR="$(cd -P "$( dirname "$SOURCE")"&&pwd)"
15
+
SOURCE="$(readlink "$SOURCE")"
16
+
[[ $SOURCE!= /* ]] && SOURCE="$DIR/$SOURCE"# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
17
17
done
18
18
DIR="$(cd -P "$( dirname "$SOURCE")"&&pwd)"
19
19
20
20
# Do not "cd $DIR". For localRun, the current directory is expected to be the repo location on disk.
21
21
22
22
# Run
23
23
shopt -s nocasematch
24
-
if [[ "$1"=="localRun" ]];then
25
-
"$DIR"/bin/Runner.Listener $*
26
-
else
27
-
"$DIR"/bin/Runner.Listener run $*
28
24
29
-
# Return code 3 means the run once runner received an update message.
30
-
# Sleep 5 seconds to wait for the update process finish
31
-
returnCode=$?
32
-
if [[ $returnCode== 3 ]];then
33
-
if [ !-x"$(command -v sleep)" ];then
34
-
if [ !-x"$(command -v ping)" ];then
35
-
COUNT="0"
36
-
while [[ $COUNT!= 5000 ]];do
37
-
echo"SLEEP"> /dev/null
38
-
COUNT=$[$COUNT+1]
39
-
done
40
-
else
41
-
ping -c 5 127.0.0.1 > /dev/null
42
-
fi
43
-
else
44
-
sleep 5
45
-
fi
46
-
elif [[ $returnCode== 4 ]];then
47
-
if [ !-x"$(command -v sleep)" ];then
48
-
if [ !-x"$(command -v ping)" ];then
49
-
COUNT="0"
50
-
while [[ $COUNT!= 5000 ]];do
51
-
echo"SLEEP"> /dev/null
52
-
COUNT=$[$COUNT+1]
53
-
done
54
-
else
55
-
ping -c 5 127.0.0.1 > /dev/null
56
-
fi
25
+
safe_sleep() {
26
+
if [ !-x"$(command -v sleep)" ];then
27
+
if [ !-x"$(command -v ping)" ];then
28
+
COUNT="0"
29
+
while [[ $COUNT!= 5000 ]];do
30
+
echo"SLEEP"> /dev/null
31
+
COUNT=$[$COUNT+1]
32
+
done
57
33
else
58
-
sleep 5
34
+
ping -c 5 127.0.0.1 > /dev/null
59
35
fi
36
+
else
37
+
sleep 5
38
+
fi
39
+
}
40
+
41
+
while:;
42
+
do
43
+
if [[ "$1"=="localRun" ]];then
44
+
"$DIR"/bin/Runner.Listener $*
45
+
else
60
46
"$DIR"/bin/Runner.Listener run $*
47
+
fi
48
+
49
+
returnCode=$?
50
+
if [[ $returnCode== 0 ]];then
51
+
echo"Runner listener exit with 0 return code, stop the service, no retry needed."
52
+
exit$returnCode
53
+
elif [[ $returnCode== 1 ]];then
54
+
echo"Runner listener exit with terminated error, stop the service, no retry needed."
55
+
exit$returnCode
56
+
elif [[ $returnCode== 2 ]];then
57
+
echo"Runner listener exit with retryable error, re-launch runner in 5 seconds."
58
+
safe_sleep
59
+
elif [[ $returnCode== 3 ]];then
60
+
# Sleep 5 seconds to wait for the runner update process finish
61
+
echo"Runner listener exit because of updating, re-launch runner in 5 seconds"
62
+
safe_sleep
63
+
elif [[ $returnCode== 4 ]];then
64
+
# Sleep 5 seconds to wait for the ephemeral runner update process finish
65
+
echo"Runner listener exit because of updating, re-launch ephemeral runner in 5 seconds"
0 commit comments