Update to use hot reload

This commit is contained in:
thosakwe 2017-06-06 08:30:13 -04:00
parent 58e3c02187
commit 6123740eb5
4 changed files with 17 additions and 2 deletions

View file

@ -17,7 +17,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart Packages" level="project" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -1,5 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Start Server" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application" singleton="true">
<option name="VMOptions" value="--enable-vm-service" />
<option name="filePath" value="$PROJECT_DIR$/bin/server.dart" />
<method />
</configuration>

View file

@ -2,6 +2,7 @@ import 'dart:io';
import 'dart:isolate';
import 'package:angel/angel.dart';
import 'package:angel_diagnostics/angel_diagnostics.dart';
import 'package:angel_hot/angel_hot.dart';
import 'package:intl/intl.dart';
startServer(args, {bool clustered: false, SendPort sendPort}) {
@ -21,7 +22,19 @@ startServer(args, {bool clustered: false, SendPort sendPort}) {
}
await app.configure(logRequests(logFile));
var server = await app.startServer(host, port);
HttpServer server;
// Use `package:angel_hot` in any case, EXCEPT if starting in production mode.
if (Platform.environment['ANGEL_ENV'] == 'production')
server = await app.startServer(host, port);
else {
var hot = new HotReloader(createServer, [
new Directory('bin'),
new Directory('config'),
new Directory('lib')
]);
server = await hot.startServer(host, port);
}
if (sendPort == null) {
print('Listening at http://${server.address.address}:${server.port}');

View file

@ -7,6 +7,7 @@ homepage: https://github.com/angel-dart/angel
dependencies:
angel_common: ^1.0.0
angel_configuration: ^1.0.0
angel_hot: ^1.0.0-rc.1
angel_multiserver: ^1.0.0
dev_dependencies:
grinder: ^0.8.0