This commit is contained in:
Tobe O 2019-05-01 05:41:26 -04:00
parent 37a14c3bee
commit 5156ab826b
5 changed files with 23 additions and 9 deletions

View file

@ -1,3 +1,6 @@
# 2.0.5
* Use `dart:developer` to find the Observatory URI.
# 2.0.4
* Forcibly close app loggers on shutdown.

View file

@ -4,7 +4,6 @@ import 'server.dart';
main() async {
var hot = new HotReloader(createServer, [
new Directory('src'),
new Directory('src'),
'server.dart',
// Also allowed: Platform.script,

View file

@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:angel_framework/angel_framework.dart';

View file

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'dart:developer' as dev;
import 'dart:io';
import 'dart:isolate';
import 'package:angel_framework/angel_framework.dart';
@ -11,6 +12,7 @@ import 'package:glob/glob.dart';
import 'package:html_builder/elements.dart';
import 'package:html_builder/html_builder.dart';
import 'package:io/ansi.dart';
import 'package:path/path.dart' as p;
import 'package:vm_service_lib/vm_service_lib.dart' as vm;
import 'package:vm_service_lib/vm_service_lib_io.dart' as vm;
import 'package:watcher/watcher.dart';
@ -149,11 +151,21 @@ class HotReloader {
'WARNING: You have instantiated a HotReloader without passing `--enable-vm-service` or `--observe` to the Dart VM. Hot reloading will be disabled.'));
isHot = false;
} else {
_client = await vm.vmServiceConnect(
vmServiceHost ?? 'localhost', vmServicePort ?? 8181);
var info = await dev.Service.getInfo();
var uri = info.serverUri;
uri = uri.replace(path: p.join(uri.path, 'ws'));
if (uri.scheme == 'https')
uri = uri.replace(scheme: 'wss');
else
uri = uri.replace(scheme: 'ws');
_client = await vm.vmServiceConnectUri(uri.toString());
_vmachine ??= await _client.getVM();
_mainIsolate ??= _vmachine.isolates.first;
await _client.setExceptionPauseMode(_mainIsolate.id, 'None');
for (var isolate in _vmachine.isolates) {
await _client.setExceptionPauseMode(isolate.id, 'None');
}
await _listenToFilesystem();
}
@ -169,9 +181,7 @@ class HotReloader {
if (enableHotkeys) {
var serverUri = new Uri(
scheme: 'http', host: server.address.address, port: server.port);
var host = vmServiceHost == 'localhost' ? '127.0.0.1' : vmServiceHost;
var observatoryUri =
new Uri(scheme: 'http', host: host, port: vmServicePort);
var observatoryUri = await dev.Service.getInfo().then((i) => i.serverUri);
print(styleBold.wrap(
'\n🔥 To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".'));

View file

@ -1,10 +1,10 @@
name: angel_hot
description: Supports hot reloading/hot code push of Angel servers on file changes.
version: 2.0.4
version: 2.0.5
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/hot
environment:
sdk: ">=2.0.0-dev <3.0.0"
sdk: ">=2.0.0 <3.0.0"
dependencies:
angel_framework: ^2.0.0-alpha
angel_websocket: ^2.0.0-alpha
@ -12,6 +12,7 @@ dependencies:
glob: ^1.0.0
html_builder: ^1.0.0
io: ^0.3.2
path: ^1.0.0
vm_service_lib: ^0.3.5
watcher: ^0.9.0
dev_dependencies: