Revision 8a6723d5
Added by Renato Botelho over 9 years ago
tools/build_snapshots.sh | ||
---|---|---|
78 | 78 |
# will sleep for a bit and check for new commits |
79 | 79 |
# in between sleeping for short durations. |
80 | 80 |
snapshots_sleep_between_runs() { |
81 |
# Handle SIGINFO (ctrl+T) and restart build |
|
82 |
trap restart_build SIGINFO |
|
83 |
|
|
84 |
# Initialize variables that keep track of last commit |
|
85 |
[ -z "${LAST_COMMIT}" ] \ |
|
86 |
&& export LAST_COMMIT=${CURRENT_COMMIT} |
|
87 |
|
|
88 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Sleeping for at least $minsleepvalue, at most $maxsleepvalue in between snapshot builder runs." |
|
89 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Last known commit: ${LAST_COMMIT}" |
|
90 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Freezing build process at $(date)" |
|
91 |
echo ">>> Press ctrl+T to start a new build" |
|
92 |
COUNTER=0 |
|
81 | 93 |
_sleeping=1 |
94 |
while [ ${COUNTER} -lt ${minsleepvalue} ]; do |
|
95 |
sleep 1 |
|
96 |
COUNTER=$((COUNTER + 1)) |
|
97 |
done |
|
98 |
|
|
99 |
if [ ${COUNTER} -lt ${maxsleepvalue} ]; then |
|
100 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Thawing build process and resuming checks for pending commits at $(date)." |
|
101 |
echo ">>> Press ctrl+T to start a new build" |
|
102 |
fi |
|
103 |
|
|
82 | 104 |
while [ $COUNTER -lt $maxsleepvalue ]; do |
83 | 105 |
sleep 1 |
84 | 106 |
# Update this repo each 60 seconds |
... | ... | |
95 | 117 |
COUNTER=$(($COUNTER + 1)) |
96 | 118 |
done |
97 | 119 |
_sleeping=0 |
120 |
|
|
98 | 121 |
if [ $COUNTER -ge $maxsleepvalue ]; then |
99 | 122 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Sleep timer expired. Restarting build." |
100 | 123 |
COUNTER=0 |
101 | 124 |
fi |
125 |
|
|
126 |
trap "-" SIGINFO |
|
102 | 127 |
} |
103 | 128 |
|
104 | 129 |
git_last_commit |
105 | 130 |
|
106 |
# Handle SIGINFO (ctrl+T) and restart build |
|
107 |
trap restart_build SIGINFO |
|
108 |
|
|
109 | 131 |
# Main builder loop |
110 | 132 |
while [ /bin/true ]; do |
111 | 133 |
BUILDCOUNTER=$((${BUILDCOUNTER}+1)) |
... | ... | |
123 | 145 |
exit |
124 | 146 |
fi |
125 | 147 |
|
126 |
# Initialize variables that keep track of last commit |
|
127 |
[ -z "${LAST_COMMIT}" ] \ |
|
128 |
&& export LAST_COMMIT=${CURRENT_COMMIT} |
|
129 |
|
|
130 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Sleeping for at least $minsleepvalue, at most $maxsleepvalue in between snapshot builder runs." |
|
131 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Last known commit: ${LAST_COMMIT}" |
|
132 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Freezing build process at $(date)" |
|
133 |
echo ">>> Press ctrl+T to start a new build" |
|
134 |
COUNTER=0 |
|
135 |
_sleeping=1 |
|
136 |
while [ ${COUNTER} -lt ${minsleepvalue} ]; do |
|
137 |
sleep 1 |
|
138 |
COUNTER=$((COUNTER + 1)) |
|
139 |
done |
|
140 |
_sleeping=0 |
|
141 |
|
|
142 |
if [ ${COUNTER} -lt ${maxsleepvalue} ]; then |
|
143 |
${BUILDER_ROOT}/build.sh --snapshot-update-status ">>> Thawing build process and resuming checks for pending commits at $(date)." |
|
144 |
echo ">>> Press ctrl+T to start a new build" |
|
145 |
|
|
146 |
# Count some sheep or wait until a new commit turns up |
|
147 |
# for one days time. We will wake up if a new commit |
|
148 |
# is detected during sleepy time. |
|
149 |
snapshots_sleep_between_runs |
|
150 |
fi |
|
148 |
# Count some sheep or wait until a new commit turns up |
|
149 |
# for one days time. We will wake up if a new commit |
|
150 |
# is detected during sleepy time. |
|
151 |
snapshots_sleep_between_runs |
|
151 | 152 |
done |
Also available in: Unified diff
Handle all sleep operations inside snapshots_sleep_between_runs()