OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of vmservice_io; | 5 part of vmservice_io; |
6 | 6 |
7 final bool silentObservatory = const bool.fromEnvironment('SILENT_OBSERVATORY'); | 7 final bool silentObservatory = const bool.fromEnvironment('SILENT_OBSERVATORY'); |
8 | 8 |
9 void serverPrint(String s) { | 9 void serverPrint(String s) { |
10 if (silentObservatory) { | 10 if (silentObservatory) { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 354 } |
355 | 355 |
356 // poll for the network for ~10 seconds. | 356 // poll for the network for ~10 seconds. |
357 int attempts = 0; | 357 int attempts = 0; |
358 final int maxAttempts = 10; | 358 final int maxAttempts = 10; |
359 while (!await poll()) { | 359 while (!await poll()) { |
360 attempts++; | 360 attempts++; |
361 serverPrint("Observatory server failed to start after $attempts tries"); | 361 serverPrint("Observatory server failed to start after $attempts tries"); |
362 if (attempts > maxAttempts) { | 362 if (attempts > maxAttempts) { |
363 serverPrint('Could not start Observatory HTTP server:\n' | 363 serverPrint('Could not start Observatory HTTP server:\n' |
364 '$pollError\n$pollStack\n'); | 364 '$pollError\n$pollStack\n'); |
365 _notifyServerState(""); | 365 _notifyServerState(""); |
366 onServerAddressChange(null); | 366 onServerAddressChange(null); |
367 return this; | 367 return this; |
368 } | 368 } |
369 await new Future<Null>.delayed(const Duration(seconds: 1)); | 369 await new Future<Null>.delayed(const Duration(seconds: 1)); |
370 } | 370 } |
371 _server.listen(_requestHandler, cancelOnError: true); | 371 _server.listen(_requestHandler, cancelOnError: true); |
372 serverPrint('Observatory listening on $serverAddress'); | 372 serverPrint('Observatory listening on $serverAddress'); |
373 if (Platform.isFuchsia) { | 373 if (Platform.isFuchsia) { |
374 // Create a file with the port number. | 374 // Create a file with the port number. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 _server = null; | 415 _server = null; |
416 serverPrint('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); | 416 serverPrint('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); |
417 _notifyServerState(""); | 417 _notifyServerState(""); |
418 onServerAddressChange(null); | 418 onServerAddressChange(null); |
419 return this; | 419 return this; |
420 }); | 420 }); |
421 } | 421 } |
422 } | 422 } |
423 | 423 |
424 void _notifyServerState(String uri) native "VMServiceIO_NotifyServerState"; | 424 void _notifyServerState(String uri) native "VMServiceIO_NotifyServerState"; |
OLD | NEW |