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

Side by Side Diff: sdk/lib/_internal/pub/lib/src/command/serve.dart

Issue 575733002: Revert "try again to not auto start editor port" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 pub.command.serve; 5 library pub.command.serve;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 28 matching lines...) Expand all
39 /// 39 ///
40 /// This will print a usage error and exit if the specified port is invalid. 40 /// This will print a usage error and exit if the specified port is invalid.
41 int get adminPort { 41 int get adminPort {
42 var adminPort = commandOptions['admin-port']; 42 var adminPort = commandOptions['admin-port'];
43 return adminPort == null ? null : parseInt(adminPort, 'admin port'); 43 return adminPort == null ? null : parseInt(adminPort, 'admin port');
44 } 44 }
45 45
46 /// `true` if Dart entrypoints should be compiled to JavaScript. 46 /// `true` if Dart entrypoints should be compiled to JavaScript.
47 bool get useDart2JS => commandOptions['dart2js']; 47 bool get useDart2JS => commandOptions['dart2js'];
48 48
49 /// `true` if the admin server URL should be displayed on startup.
50 bool get logAdminUrl => commandOptions['log-admin-url'];
51
49 BarbackMode get defaultMode => BarbackMode.DEBUG; 52 BarbackMode get defaultMode => BarbackMode.DEBUG;
50 53
51 List<String> get defaultSourceDirectories => ["web", "test"]; 54 List<String> get defaultSourceDirectories => ["web", "test"];
52 55
53 /// This completer is used to keep pub running (by not completing) and to 56 /// This completer is used to keep pub running (by not completing) and to
54 /// pipe fatal errors to pub's top-level error-handling machinery. 57 /// pipe fatal errors to pub's top-level error-handling machinery.
55 final _completer = new Completer(); 58 final _completer = new Completer();
56 59
57 ServeCommand() { 60 ServeCommand() {
58 commandParser.addOption('hostname', defaultsTo: 'localhost', 61 commandParser.addOption('hostname', defaultsTo: 'localhost',
59 help: 'The hostname to listen on.'); 62 help: 'The hostname to listen on.');
60 commandParser.addOption('port', defaultsTo: '8080', 63 commandParser.addOption('port', defaultsTo: '8080',
61 help: 'The base port to listen on.'); 64 help: 'The base port to listen on.');
62 65
63 // TODO(nweiz): Remove once editor also removes this. This is now a NOOP. 66 // TODO(rnystrom): A hidden option to print the URL that the admin server
64 // Check on http://dartbug.com/20960 67 // is bound to on startup. Since this is currently only used for the Web
68 // Socket interface, we don't want to show it to users, but the tests and
69 // Editor need this logged to know what port to bind to.
70 // Remove this (and always log) when #16954 is fixed.
65 commandParser.addFlag('log-admin-url', defaultsTo: false, hide: true); 71 commandParser.addFlag('log-admin-url', defaultsTo: false, hide: true);
66 72
67 // TODO(nweiz): Make this public when issue 16954 is fixed. 73 // TODO(nweiz): Make this public when issue 16954 is fixed.
68 commandParser.addOption('admin-port', hide: true); 74 commandParser.addOption('admin-port', hide: true);
69 75
70 commandParser.addFlag('dart2js', defaultsTo: true, 76 commandParser.addFlag('dart2js', defaultsTo: true,
71 help: 'Compile Dart to JavaScript.'); 77 help: 'Compile Dart to JavaScript.');
72 commandParser.addFlag('force-poll', defaultsTo: false, 78 commandParser.addFlag('force-poll', defaultsTo: false,
73 help: 'Force the use of a polling filesystem watcher.'); 79 help: 'Force the use of a polling filesystem watcher.');
74 } 80 }
75 81
76 Future onRunTransformerCommand() async { 82 Future onRunTransformerCommand() async {
77 var port = parseInt(commandOptions['port'], 'port'); 83 var port = parseInt(commandOptions['port'], 'port');
78 var adminPort = commandOptions['admin-port'] == null ? null : 84 var adminPort = commandOptions['admin-port'] == null ? null :
79 parseInt(commandOptions['admin-port'], 'admin port'); 85 parseInt(commandOptions['admin-port'], 'admin port');
80 86
81 var watcherType = commandOptions['force-poll'] ? 87 var watcherType = commandOptions['force-poll'] ?
82 WatcherType.POLLING : WatcherType.AUTO; 88 WatcherType.POLLING : WatcherType.AUTO;
83 89
84 var environment = await AssetEnvironment.create(entrypoint, mode, 90 var environment = await AssetEnvironment.create(entrypoint, mode,
85 watcherType: watcherType, hostname: hostname, basePort: port, 91 watcherType: watcherType, hostname: hostname, basePort: port,
86 useDart2JS: useDart2JS); 92 useDart2JS: useDart2JS);
87 var directoryLength = sourceDirectories.map((dir) => dir.length) 93 var directoryLength = sourceDirectories.map((dir) => dir.length)
88 .reduce(math.max); 94 .reduce(math.max);
89 95
90 if (adminPort != null) { 96 var server = await environment.startAdminServer(adminPort);
91 var server = await environment.startAdminServer(adminPort); 97 server.results.listen((_) {
92 server.results.listen((_) { 98 // The admin server produces no result values.
93 // The admin server produces no result values. 99 assert(false);
94 assert(false); 100 }, onError: _fatalError);
95 }, onError: _fatalError);
96 101
102 if (logAdminUrl) {
97 log.message("Running admin server on " 103 log.message("Running admin server on "
98 "${log.bold('http://$hostname:${server.port}')}"); 104 "${log.bold('http://$hostname:${server.port}')}");
99 } 105 }
100 106
101 // Start up the servers. We pause updates while this is happening so 107 // Start up the servers. We pause updates while this is happening so
102 // that we don't log spurious build results in the middle of listing 108 // that we don't log spurious build results in the middle of listing
103 // out the bound servers. 109 // out the bound servers.
104 environment.pauseUpdates(); 110 environment.pauseUpdates();
105 for (var directory in sourceDirectories) { 111 for (var directory in sourceDirectories) {
106 await _startServer(environment, directory, directoryLength); 112 await _startServer(environment, directory, directoryLength);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 "${padRight(server.rootDirectory, directoryLength)} " 169 "${padRight(server.rootDirectory, directoryLength)} "
164 "on ${log.bold('http://$hostname:${server.port}')}"); 170 "on ${log.bold('http://$hostname:${server.port}')}");
165 } 171 }
166 172
167 /// Reports [error] and exits the server. 173 /// Reports [error] and exits the server.
168 void _fatalError(error, [stackTrace]) { 174 void _fatalError(error, [stackTrace]) {
169 if (_completer.isCompleted) return; 175 if (_completer.isCompleted) return;
170 _completer.completeError(error, stackTrace); 176 _completer.completeError(error, stackTrace);
171 } 177 }
172 } 178 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/README.md ('k') | sdk/lib/_internal/pub_generated/lib/src/command/serve.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698