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 library vmservice_io; | 5 library vmservice_io; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'dart:isolate'; | 10 import 'dart:isolate'; |
11 import 'dart:_vmservice'; | 11 import 'dart:_vmservice'; |
12 | 12 |
13 part 'loader.dart'; | 13 part 'loader.dart'; |
14 part 'resources.dart'; | |
15 part 'server.dart'; | 14 part 'server.dart'; |
16 | 15 |
17 // The TCP ip/port that the HTTP server listens on. | 16 // The TCP ip/port that the HTTP server listens on. |
18 int _port; | 17 int _port; |
19 String _ip; | 18 String _ip; |
20 // Should the HTTP server auto start? | 19 // Should the HTTP server auto start? |
21 bool _autoStart; | 20 bool _autoStart; |
22 | 21 |
23 bool _isWindows = false; | 22 bool _isWindows = false; |
24 | 23 |
25 var _signalWatch; | 24 var _signalWatch; |
26 var _signalSubscription; | 25 var _signalSubscription; |
27 | 26 |
28 // HTTP servr. | 27 // HTTP server. |
29 Server server; | 28 Server server; |
30 Future<Server> serverFuture; | 29 Future<Server> serverFuture; |
| 30 Map<String, Asset> assets; |
31 | 31 |
32 _onShutdown() { | 32 _onShutdown() { |
33 if (server != null) { | 33 if (server != null) { |
34 server.close(true).catchError((e, st) { | 34 server.close(true).catchError((e, st) { |
35 print("Error in vm-service shutdown: $e\n$st\n"); | 35 print("Error in vm-service shutdown: $e\n$st\n"); |
36 }); | 36 }); |
37 } | 37 } |
38 if (_signalSubscription != null) { | 38 if (_signalSubscription != null) { |
39 _signalSubscription.cancel(); | 39 _signalSubscription.cancel(); |
40 _signalSubscription = null; | 40 _signalSubscription = null; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 _bootServer() { | 44 _bootServer() { |
45 // Load resources. | 45 try { |
46 _triggerResourceLoad(); | 46 assets = Asset.request(); |
| 47 } catch (e) { |
| 48 print('Could not load Observatory assets: $e'); |
| 49 } |
47 // Lazily create service. | 50 // Lazily create service. |
48 var service = new VMService(); | 51 var service = new VMService(); |
49 service.onShutdown = _onShutdown; | 52 service.onShutdown = _onShutdown; |
50 // Lazily create server. | 53 // Lazily create server. |
51 server = new Server(service, _ip, _port); | 54 server = new Server(service, _ip, _port); |
52 } | 55 } |
53 | 56 |
54 _clearFuture(_) { | 57 _clearFuture(_) { |
55 serverFuture = null; | 58 serverFuture = null; |
56 } | 59 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // else { | 100 // else { |
98 // var service = new VMService(); | 101 // var service = new VMService(); |
99 // service.onShutdown = _onShutdown; | 102 // service.onShutdown = _onShutdown; |
100 // } | 103 // } |
101 scriptLoadPort.handler = _processLoadRequest; | 104 scriptLoadPort.handler = _processLoadRequest; |
102 // Register signal handler after a small delay to avoid stalling main | 105 // Register signal handler after a small delay to avoid stalling main |
103 // isolate startup. | 106 // isolate startup. |
104 new Timer(_shortDelay, _registerSignalHandler); | 107 new Timer(_shortDelay, _registerSignalHandler); |
105 return scriptLoadPort; | 108 return scriptLoadPort; |
106 } | 109 } |
OLD | NEW |