@@ -11,6 +11,9 @@ BUILD_INTERVAL=${BUILD_INTERVAL:-1}
11
11
BUILD_INTERVAL_SECONDS=$(( ($BUILD_INTERVAL - 1 )* 24 * 3600 ))
12
12
# start build at this time (GMT):
13
13
BUILD_TIME=${BUILD_TIME:- 23: 00: 00}
14
+ # option to launch build automatically at early hours
15
+ # as a mitigation to crashed builds. zero value disables this feature
16
+ AUTO_REBUILD_HOUR=${AUTO_REBUILD_HOUR:- 6}
14
17
BUILDER_TYPE=${BUILDER_TYPE:- dev}
15
18
16
19
# param: message text content
@@ -22,9 +25,18 @@ function post_slack_message {
22
25
fi
23
26
}
24
27
28
+ # build should be started immediately if service starts before 06:00
29
+ # because that is considered as a restart after a service failure
30
+ HOUR=$( date +%H)
31
+ if [[ " $HOUR " -lt " $AUTO_REBUILD_HOUR " ]]; then
32
+ BUILD_AT_LAUNCH=1
33
+ else
34
+ BUILD_AT_LAUNCH=0
35
+ fi
36
+
25
37
# run data build loop forever, unless build interval is set to zero
26
38
while true ; do
27
- if [[ " $BUILD_INTERVAL " -gt 0 ]]; then
39
+ if [[ " $BUILD_INTERVAL " -gt 0 ]] && [[ " $BUILD_AT_LAUNCH " -eq 0 ]] ; then
28
40
SLEEP=$(( $(date - u - d $BUILD_TIME +% s) - $(date - u +% s) + 1 ))
29
41
if [[ " $SLEEP " -le 0 ]]; then
30
42
# today's build time is gone, start counting from tomorrow
@@ -36,6 +48,8 @@ while true; do
36
48
sleep $SLEEP
37
49
fi
38
50
51
+ BUILD_AT_LAUNCH=0 # reset
52
+
39
53
echo " ** Launching OTP data builder"
40
54
41
55
# note: busybox timeout
0 commit comments