49
49
closeSerialLogOutput func ()
50
50
)
51
51
52
+ var timeStart = time .Now ()
53
+
52
54
func main () {
53
55
if configureSerialLogOutput != nil {
54
56
configureSerialLogOutput ()
@@ -88,6 +90,9 @@ func main() {
88
90
if ! awaitNetwork () {
89
91
sleepFatalf ("network didn't become reachable" )
90
92
}
93
+ timeNetwork := time .Now ()
94
+ netDelay := prettyDuration (timeNetwork .Sub (timeStart ))
95
+ log .Printf ("network up after %v" , netDelay )
91
96
92
97
// Note: we name it ".exe" for Windows, but the name also
93
98
// works fine on Linux, etc.
@@ -101,6 +106,8 @@ func main() {
101
106
log .Fatal (err )
102
107
}
103
108
}
109
+ downloadDelay := prettyDuration (time .Since (timeNetwork ))
110
+ log .Printf ("downloaded buildlet in %v" , downloadDelay )
104
111
105
112
env := os .Environ ()
106
113
if isUnix () && os .Getuid () == 0 {
@@ -111,6 +118,8 @@ func main() {
111
118
env = append (env , "HOME=/root" )
112
119
}
113
120
}
121
+ env = append (env , fmt .Sprintf ("GO_STAGE0_NET_DELAY=%v" , netDelay ))
122
+ env = append (env , fmt .Sprintf ("GO_STAGE0_DL_DELAY=%v" , downloadDelay ))
114
123
115
124
cmd := exec .Command (target )
116
125
cmd .Stdout = os .Stdout
@@ -194,13 +203,13 @@ func awaitNetwork() bool {
194
203
for time .Now ().Before (deadline ) {
195
204
t0 := time .Now ()
196
205
if isNetworkUp () {
197
- log .Printf ("network is up." )
198
206
return true
199
207
}
200
208
failAfter := time .Since (t0 )
201
209
if now := time .Now (); now .After (lastSpam .Add (5 * time .Second )) {
202
- const round = time .Second / 10
203
- log .Printf ("network still down; probe failure took %v" , failAfter / round * round )
210
+ log .Printf ("network still down for %v; probe failure took %v" ,
211
+ prettyDuration (time .Since (timeStart )),
212
+ prettyDuration (failAfter ))
204
213
lastSpam = now
205
214
}
206
215
time .Sleep (1 * time .Second )
@@ -209,6 +218,9 @@ func awaitNetwork() bool {
209
218
return false
210
219
}
211
220
221
+ // isNetworkUp reports whether the network is up by hitting an
222
+ // known-up HTTP server. It might block for a few seconds before
223
+ // returning an answer.
212
224
func isNetworkUp () bool {
213
225
const probeURL = "http://farmer.golang.org/netcheck" // 404 is fine.
214
226
c := & http.Client {
@@ -360,3 +372,8 @@ func untarMode() {
360
372
log .Fatalf ("Untarring %q to %q: %v" , * untarFile , * untarDestDir , err )
361
373
}
362
374
}
375
+
376
+ func prettyDuration (d time.Duration ) time.Duration {
377
+ const round = time .Second / 10
378
+ return d / round * round
379
+ }
0 commit comments