protevus/bin/dev.dart

26 lines
937 B
Dart
Raw Normal View History

2017-10-19 21:53:33 +00:00
import 'dart:io';
2018-12-31 01:40:24 +00:00
import 'package:angel/src/pretty_logging.dart';
2017-10-19 21:53:33 +00:00
import 'package:angel/angel.dart';
2018-12-31 01:39:22 +00:00
import 'package:angel_container/mirrors.dart';
2017-10-19 21:53:33 +00:00
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_hot/angel_hot.dart';
2018-12-31 01:40:24 +00:00
import 'package:logging/logging.dart';
2017-10-19 21:53:33 +00:00
main() async {
// Watch the config/ and web/ directories for changes, and hot-reload the server.
2018-12-31 01:40:24 +00:00
var hot = new HotReloader(() async {
var app = new Angel(reflector: MirrorsReflector());
2017-10-19 21:53:33 +00:00
await app.configure(configureServer);
2018-12-31 01:40:24 +00:00
hierarchicalLoggingEnabled = true;
2019-02-06 21:57:53 +00:00
app.logger = new Logger.detached('{{angel}}')..onRecord.listen(prettyLog);
app.shutdownHooks.add((_) => app.logger.clearListeners());
2018-12-31 01:40:24 +00:00
return app;
2017-10-19 21:53:33 +00:00
}, [
2018-12-31 01:40:24 +00:00
new Directory('config'),
new Directory('lib'),
2017-10-19 21:53:33 +00:00
]);
var server = await hot.startServer('127.0.0.1', 3000);
2018-12-31 16:15:48 +00:00
print('{{angel}} server listening at http://${server.address.address}:${server.port}');
2017-10-19 21:53:33 +00:00
}