Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(935)

Unified Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 237113002: SIGQUIT toggles VM service HTTP server (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmservice/vmservice_io.dart
diff --git a/runtime/bin/vmservice/vmservice_io.dart b/runtime/bin/vmservice/vmservice_io.dart
index d0bccea61a382921fed6663eb0ebc95c44a954ac..1a972d0c3e1aff3edd9a3b53c2169cae8124dd31 100644
--- a/runtime/bin/vmservice/vmservice_io.dart
+++ b/runtime/bin/vmservice/vmservice_io.dart
@@ -8,6 +8,7 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
+import 'dart:mirrors';
import 'dart:vmservice';
part 'resources.dart';
@@ -16,14 +17,52 @@ part 'server.dart';
// The TCP ip/port that the HTTP server listens on.
int _port;
String _ip;
+// Should the HTTP server auto start?
+bool _autoStart;
+
+// HTTP servr.
+Server server;
+Future<Server> serverFuture;
// The VM service instance.
VMService service;
+void _onSignal(ProcessSignal signal) {
+ if (serverFuture != null) {
+ // Still waiting.
+ return;
+ }
+ // Toggle HTTP server.
+ if (server.running) {
+ serverFuture = server.shutdown(true).then((_) {
+ serverFuture = null;
+ });
+ } else {
+ serverFuture = server.startup().then((_) {
+ serverFuture = null;
+ });
+ }
+}
+
main() {
// Get VMService.
service = new VMService();
// Start HTTP server.
- var server = new Server(service, _ip, _port);
- server.startServer();
+ server = new Server(service, _ip, _port);
+ if (_autoStart) {
+ server.startup();
+ }
+
+ bool useSIGQUIT = true;
+ // Listen for SIGQUIT.
+ if (useSIGQUIT) {
+ var io = currentMirrorSystem().findLibrary(const Symbol('dart.io'));
+ var c = MirrorSystem.getSymbol('_ProcessUtils', io);
+ var m = MirrorSystem.getSymbol('_watchSignalInternal', io);
+ var processUtils = io.declarations[c];
+ processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal);
+ } else {
+ ProcessSignal.SIGUSR1.watch().listen(_onSignal);
+ }
}
+
« no previous file with comments | « runtime/bin/vmservice/server.dart ('k') | runtime/bin/vmservice_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698