| 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'; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 serverFuture = server.shutdown(true).then((_) { | 37 serverFuture = server.shutdown(true).then((_) { |
| 38 serverFuture = null; | 38 serverFuture = null; |
| 39 }); | 39 }); |
| 40 } else { | 40 } else { |
| 41 serverFuture = server.startup().then((_) { | 41 serverFuture = server.startup().then((_) { |
| 42 serverFuture = null; | 42 serverFuture = null; |
| 43 }); | 43 }); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 main() { | 47 void registerSignalHandler() { |
| 48 // Get VMService. | |
| 49 service = new VMService(); | |
| 50 // Start HTTP server. | |
| 51 server = new Server(service, _ip, _port); | |
| 52 if (_autoStart) { | |
| 53 server.startup(); | |
| 54 } | |
| 55 | |
| 56 bool useSIGQUIT = true; | 48 bool useSIGQUIT = true; |
| 57 // Listen for SIGQUIT. | 49 // Listen for SIGQUIT. |
| 58 if (useSIGQUIT) { | 50 if (useSIGQUIT) { |
| 59 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io')); | 51 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io')); |
| 60 var c = MirrorSystem.getSymbol('_ProcessUtils', io); | 52 var c = MirrorSystem.getSymbol('_ProcessUtils', io); |
| 61 var m = MirrorSystem.getSymbol('_watchSignalInternal', io); | 53 var m = MirrorSystem.getSymbol('_watchSignalInternal', io); |
| 62 var processUtils = io.declarations[c]; | 54 var processUtils = io.declarations[c]; |
| 63 processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal); | 55 processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal); |
| 64 } else { | 56 } else { |
| 65 ProcessSignal.SIGUSR1.watch().listen(_onSignal); | 57 ProcessSignal.SIGUSR1.watch().listen(_onSignal); |
| 66 } | 58 } |
| 67 } | 59 } |
| 68 | 60 |
| 61 |
| 62 main() { |
| 63 // Get VMService. |
| 64 service = new VMService(); |
| 65 // Start HTTP server. |
| 66 server = new Server(service, _ip, _port); |
| 67 if (_autoStart) { |
| 68 server.startup(); |
| 69 } |
| 70 |
| 71 try { |
| 72 registerSignalHandler(); |
| 73 } catch (_) { |
| 74 // Listening for signals will fail on Windows. |
| 75 } |
| 76 } |
| OLD | NEW |