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';
|
2016-04-22 02:56:21 +00:00
|
|
|
import 'package:angel_framework/angel_framework.dart';
|
2016-09-19 07:38:30 +00:00
|
|
|
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-04-29 01:22:53 +00:00
|
|
|
Angel app = await createServer();
|
2016-09-19 07:38:30 +00:00
|
|
|
DateFormat dateFormat = new DateFormat("y-MM-dd");
|
2016-06-23 21:54:10 +00:00
|
|
|
InternetAddress host = new InternetAddress(app.properties['host']);
|
|
|
|
int port = app.properties['port'];
|
2016-09-19 07:38:30 +00:00
|
|
|
var now = new DateTime.now();
|
2016-06-23 21:54:10 +00:00
|
|
|
|
2016-09-19 07:38:30 +00:00
|
|
|
await new DiagnosticsServer(app, new File("logs/${dateFormat.format(now)}.txt")).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);
|
|
|
|
}
|
|
|
|
}
|