Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5c14444b
Commit
5c14444b
authored
Aug 17, 2016
by
John McCutchan
Committed by
GitHub
Aug 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trigger a hot reload / full restart based on SIGUSR1 and SIGUSR2 (#5453)
parent
2326f552
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
51 deletions
+16
-51
run.dart
packages/flutter_tools/lib/src/commands/run.dart
+7
-20
hot.dart
packages/flutter_tools/lib/src/hot.dart
+1
-31
resident_runner.dart
packages/flutter_tools/lib/src/resident_runner.dart
+8
-0
No files found.
packages/flutter_tools/lib/src/commands/run.dart
View file @
5c14444b
...
...
@@ -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
(
...
...
packages/flutter_tools/lib/src/hot.dart
View file @
5c14444b
...
...
@@ -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
<
String
>
_startupDependencies
;
final
AssetBundle
bundle
=
new
AssetBundle
();
final
File
pipe
;
Future
<
String
>
_readFromControlPipe
()
async
{
final
Stream
<
List
<
int
>>
stream
=
pipe
.
openRead
();
final
List
<
int
>
bytes
=
await
stream
.
first
;
final
String
string
=
new
String
.
fromCharCodes
(
bytes
).
trim
();
return
string
;
}
Future
<
Null
>
_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
<
int
>
run
({
...
...
@@ -300,8 +272,6 @@ class HotRunner extends ResidentRunner {
_loaderShowMessage
(
'Launching...'
);
await
_launchFromDevFS
(
_package
,
_mainPath
);
_startReadingFromControlPipe
();
printStatus
(
'Application running.'
);
setupTerminal
();
...
...
packages/flutter_tools/lib/src/resident_runner.dart
View file @
5c14444b
...
...
@@ -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
<
Null
>
startEchoingDeviceLog
()
async
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment