This reverts commit 7750872251.
This commit is contained in:
@@ -480,6 +480,21 @@ Future<Null> runAndCaptureAsyncStacks(Future<Null> callback()) {
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
/// Return an unused TCP port number.
|
||||
Future<int> findAvailablePort() async {
|
||||
int port = 20000;
|
||||
while (true) {
|
||||
try {
|
||||
final ServerSocket socket =
|
||||
await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, port); // ignore: deprecated_member_use
|
||||
await socket.close();
|
||||
return port;
|
||||
} catch (_) {
|
||||
port++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool canRun(String path) => _processManager.canRun(path);
|
||||
|
||||
String extractCloudAuthTokenArg(List<String> rawArgs) {
|
||||
@@ -502,20 +517,13 @@ String extractCloudAuthTokenArg(List<String> rawArgs) {
|
||||
return token;
|
||||
}
|
||||
|
||||
/// Tries to extract a port from the string.
|
||||
///
|
||||
/// The `prefix`, if specified, is a regular expression pattern and must not contain groups.
|
||||
///
|
||||
/// The `multiLine` flag should be set to true if `line` is actually a buffer of many lines.
|
||||
int parseServicePort(String line, {
|
||||
String prefix = 'An Observatory debugger .* is available at: ',
|
||||
bool multiLine = false,
|
||||
}) {
|
||||
// e.g. "An Observatory debugger and profiler on ... is available at: http://127.0.0.1:8100/"
|
||||
final RegExp pattern = new RegExp('$prefix(\\S+:(\\d+)/\\S*)\$', multiLine: multiLine);
|
||||
final Match match = pattern.firstMatch(line);
|
||||
print(pattern);
|
||||
print(match);
|
||||
// "An Observatory debugger and profiler on ... is available at: http://127.0.0.1:8100/"
|
||||
final RegExp _kObservatoryRegExp = new RegExp(r'An Observatory debugger .* is available at: (\S+:(\d+))');
|
||||
|
||||
bool lineContainsServicePort(String line) => line.contains(_kObservatoryRegExp);
|
||||
|
||||
int parseServicePort(String line) {
|
||||
final Match match = _kObservatoryRegExp.firstMatch(line);
|
||||
return match == null ? null : int.parse(match.group(2));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user