From 6123740eb52ed4ddb4777452d1277df3e6e732a8 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Tue, 6 Jun 2017 08:30:13 -0400 Subject: [PATCH] Update to use hot reload --- .idea/angel.iml | 2 +- .idea/runConfigurations/Start_Server.xml | 1 + bin/common.dart | 15 ++++++++++++++- pubspec.yaml | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.idea/angel.iml b/.idea/angel.iml index 2067bad2..d218f651 100644 --- a/.idea/angel.iml +++ b/.idea/angel.iml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/.idea/runConfigurations/Start_Server.xml b/.idea/runConfigurations/Start_Server.xml index 4b1dfdcb..10afb537 100644 --- a/.idea/runConfigurations/Start_Server.xml +++ b/.idea/runConfigurations/Start_Server.xml @@ -1,5 +1,6 @@ + diff --git a/bin/common.dart b/bin/common.dart index 0dee71d8..0faf6e5d 100644 --- a/bin/common.dart +++ b/bin/common.dart @@ -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}'); diff --git a/pubspec.yaml b/pubspec.yaml index b077f933..d0854e1a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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