protevus/bin/server.dart

29 lines
760 B
Dart
Raw Normal View History

2016-09-24 20:43:48 +00:00
#!/usr/bin/env dart
2016-04-22 02:56:21 +00:00
import 'dart:async';
import 'dart:io';
import 'package:angel/angel.dart';
2016-09-19 07:38:30 +00:00
import 'package:angel_diagnostics/angel_diagnostics.dart';
import 'package:intl/intl.dart';
2016-04-22 02:56:21 +00:00
main() async {
2016-06-23 21:54:10 +00:00
runZoned(startServer, onError: onError);
}
startServer() async {
2016-09-21 05:47:44 +00:00
var app = await createServer();
var dateFormat = new DateFormat("y-MM-dd");
var logFile = new File("logs/${dateFormat.format(new DateTime.now())}.txt");
var host = new InternetAddress(app.properties['host']);
var port = app.properties['port'];
2016-06-23 21:54:10 +00:00
2016-09-21 05:47:44 +00:00
await new DiagnosticsServer(app, logFile).startServer(host, port);
2016-06-23 21:54:10 +00:00
}
2016-04-22 02:56:21 +00:00
2016-06-23 21:54:10 +00:00
onError(error, [StackTrace stackTrace]) {
stderr.writeln("Unhandled error occurred: $error");
if (stackTrace != null) {
stderr.writeln(stackTrace);
}
}