diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 0ad84a00ec..911345e87e 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -20,7 +20,6 @@ import '../runner/flutter_command.dart'; import 'build_apk.dart'; import 'install.dart'; import 'trace.dart'; -import '../base/os.dart'; abstract class RunCommandBase extends FlutterCommand { RunCommandBase() { @@ -69,10 +68,9 @@ class RunCommand extends RunCommandBase { defaultsTo: false, help: 'Run with support for hot reloading.'); - // Option to enable control over a named pipe. - argParser.addOption('control-pipe', - hide: true, - help: 'Specify a named pipe to receive commands on.'); + // Option to write the pid to a file. + argParser.addOption('pid-file', + help: 'Specify a file to write the process id to.'); // Hidden option to enable a benchmarking mode. This will run the given @@ -142,23 +140,13 @@ class RunCommand extends RunCommandBase { printError('Hot mode is not supported by this device.'); return 1; } - } else { - if (argResults['control-pipe'] != null) { - printError('--control-pipe requires --hot'); - return 1; - } } - String pipePath = argResults['control-pipe']; - File pipe; - if (pipePath != null) { - try { - // Attempt to create the pipe. - os.makePipe(pipePath); - } catch (_) { /* ignore */ } - pipe = new File(pipePath); + String pidFile = argResults['pid-file']; + if (pidFile != null) { + // Write our pid to the file. + new File(pidFile).writeAsStringSync(pid.toString()); } - ResidentRunner runner; if (argResults['hot']) { @@ -166,7 +154,6 @@ class RunCommand extends RunCommandBase { deviceForCommand, target: targetFile, debuggingOptions: options, - pipe: pipe ); } else { runner = new RunAndStayResident( diff --git a/packages/flutter_tools/lib/src/hot.dart b/packages/flutter_tools/lib/src/hot.dart index 80d98a2d32..fa98e838d6 100644 --- a/packages/flutter_tools/lib/src/hot.dart +++ b/packages/flutter_tools/lib/src/hot.dart @@ -118,8 +118,7 @@ class HotRunner extends ResidentRunner { Device device, { String target, DebuggingOptions debuggingOptions, - bool usesTerminalUI: true, - this.pipe + bool usesTerminalUI: true }) : super(device, target: target, debuggingOptions: debuggingOptions, @@ -132,33 +131,6 @@ class HotRunner extends ResidentRunner { String _projectRootPath; Set _startupDependencies; final AssetBundle bundle = new AssetBundle(); - final File pipe; - - Future _readFromControlPipe() async { - final Stream> stream = pipe.openRead(); - final List bytes = await stream.first; - final String string = new String.fromCharCodes(bytes).trim(); - return string; - } - - Future _startReadingFromControlPipe() async { - if (pipe == null) - return; - - while (true) { - // This loop will only exit if _readFromControlPipe throws an exception. - // If no exception is thrown this will keep the flutter command running - // until it is explicitly stopped via some other mechanism, for example, - // ctrl+c or sending "q" to the control pipe. - String result = await _readFromControlPipe(); - printStatus('Control pipe received "$result"'); - await processTerminalInput(result); - if (result.toLowerCase() == 'q') { - printStatus("Finished reading from control pipe"); - break; - } - } - } @override Future run({ @@ -300,8 +272,6 @@ class HotRunner extends ResidentRunner { _loaderShowMessage('Launching...'); await _launchFromDevFS(_package, _mainPath); - _startReadingFromControlPipe(); - printStatus('Application running.'); setupTerminal(); diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 166f729e41..d212009079 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -65,6 +65,14 @@ abstract class ResidentRunner { await cleanupAfterSignal(); exit(0); }); + ProcessSignal.SIGUSR1.watch().listen((ProcessSignal signal) async { + printStatus('Caught SIGUSR1'); + await restart(fullRestart: false); + }); + ProcessSignal.SIGUSR2.watch().listen((ProcessSignal signal) async { + printStatus('Caught SIGUSR2'); + await restart(fullRestart: true); + }); } Future startEchoingDeviceLog() async {