From de1d0c6dd049fba7cc0325f5282f1e668fb21205 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Tue, 4 Sep 2018 21:10:18 -0400 Subject: [PATCH] Require package:angel_production --- bin/prod.dart | 47 ++--------------------------------------------- pubspec.yaml | 1 + 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/bin/prod.dart b/bin/prod.dart index d805b24..01d40d0 100644 --- a/bin/prod.dart +++ b/bin/prod.dart @@ -1,47 +1,4 @@ -import 'dart:io'; -import 'dart:isolate'; import 'package:angel/angel.dart'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:logging/logging.dart'; +import 'package:angel_production/angel_production.dart'; -const String hostname = '127.0.0.1'; -const int port = 3000; - -void main() { - // Start a server instance in multiple isolates. - - for (int id = 0; id < Platform.numberOfProcessors; id++) - Isolate.spawn(isolateMain, id); - - isolateMain(Platform.numberOfProcessors); -} - -void isolateMain(int id) { - var app = new Angel(); - - app.configure(configureServer).then((_) async { - // In production, we'll want to log errors to a file. - // Alternatives include sending logs to a service like Sentry. - hierarchicalLoggingEnabled = true; - app.logger = new Logger('angel') - ..onRecord.listen((rec) { - if (rec.error == null) { - stdout.writeln(rec); - } else { - var err = rec.error; - if (err is AngelHttpException && err.statusCode != 500) return; - var sink = stderr; - sink..writeln(rec)..writeln(rec.error)..writeln(rec.stackTrace); - } - }); - - // Passing `startShared` to the constructor allows us to start multiple - // instances of our application concurrently, listening on a single port. - // - // This effectively lets us multi-thread the application. - var http = new AngelHttp.custom(app, startShared); - var server = await http.startServer(hostname, port); - print( - 'Instance #$id listening at http://${server.address.address}:${server.port}'); - }); -} +main(List args) => new Runner('angel', configureServer).run(args); diff --git a/pubspec.yaml b/pubspec.yaml index 78a1f47..8a7c097 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,6 +10,7 @@ dependencies: #angel_cors: ^1.0.0 # CORS support angel_framework: ^2.0.0-alpha # The core server library. #angel_jael: ^1.0.0 # Server-side templating engine + angel_production: ^1.0.0-alpha angel_static: ^2.0.0-alpha # Static file server angel_validate: ^2.0.0-alpha # Allows for validation of input data dev_dependencies: