Updated production
This commit is contained in:
parent
f2eb12551c
commit
9da4eeeb46
6 changed files with 79 additions and 48 deletions
|
@ -1,18 +1,32 @@
|
|||
# 3.0.1
|
||||
# Change Log
|
||||
|
||||
## 3.0.2
|
||||
|
||||
* Fixed NNBD issues
|
||||
* Updated references to `angel3` framework
|
||||
* Updated README
|
||||
|
||||
## 3.0.1
|
||||
|
||||
* Fixed static analysis warnings
|
||||
|
||||
# 3.0.0
|
||||
## 3.0.0
|
||||
|
||||
* Migrated to support Dart SDK 2.12.x NNBD
|
||||
|
||||
# 2.0.0
|
||||
## 2.0.0
|
||||
|
||||
* Migrated to work with Dart SDK 2.12.x Non NNBD
|
||||
|
||||
# 1.0.0
|
||||
## 1.0.0
|
||||
|
||||
* Support SSL/HTTP2.
|
||||
* Support muting the logger via `--quiet`.
|
||||
|
||||
# 1.0.0-alpha.1
|
||||
## 1.0.0-alpha.1
|
||||
|
||||
* Import `framework/http`.
|
||||
|
||||
# 1.0.0-alpha
|
||||
* Initial version.
|
||||
## 1.0.0-alpha
|
||||
|
||||
* Initial version.
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
# angel3_production
|
||||
[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_production)
|
||||
# Angel3 Production Runner
|
||||
|
||||
[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_production)
|
||||
[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety)
|
||||
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
|
||||
|
||||
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/production/LICENSE)
|
||||
|
||||
Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel.
|
||||
Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3 framework.
|
||||
|
||||
![Screenshot](screenshot.png)
|
||||
![Screenshot](angel3-screenshot.png)
|
||||
|
||||
This will become the de-facto way to run Angel applications in deployed environments, as it
|
||||
takes care of inter-isolate communication, respawning dead processes, and other housekeeping for you automatically.
|
||||
This will become the de-facto way to run Angel3 applications in deployed environments, as it takes care of inter-isolate communication, respawning dead processes, and other housekeeping for you automatically.
|
||||
|
||||
Most users will want to use the `Runner` class.
|
||||
|
||||
## `Runner`
|
||||
|
||||
`Runner` is a utility, powered by `package:args`, that is intended to be the entry point of your application.
|
||||
|
||||
Instantiate it as follows, and your file will become a command-line executable that spawns multiple instances of your
|
||||
application:
|
||||
Instantiate it as follows, and your file will become a command-line executable that spawns multiple instances of your application:
|
||||
|
||||
```dart
|
||||
import 'dart:async';
|
||||
|
@ -39,21 +39,18 @@ Future configureServer(Angel app) async {
|
|||
}
|
||||
```
|
||||
|
||||
`Runner` will automatically re-spawn crashed instances, unless `--no-respawn` is passed. This can prevent
|
||||
your server from entirely going down at the first error, and adds a layer of fault tolerance to your
|
||||
infrastructure.
|
||||
`Runner` will automatically re-spawn crashed instances, unless `--no-respawn` is passed. This can prevent your server from entirely going down at the first error, and adds a layer of fault tolerance to your infrastructure.
|
||||
|
||||
When combined with `systemd`, deploying Angel applications on Linux can be very simple.
|
||||
When combined with `systemd`, deploying Angel3 applications on Linux can be very simple.
|
||||
|
||||
## Message Passing
|
||||
|
||||
The `Runner` class uses [`package:angel3_pub_sub`](https://github.com/dukefirehawk/angel/tree/angel3/packages/pub_sub) to coordinate
|
||||
message passing between isolates.
|
||||
|
||||
When one isolate sends a message, all other isolates will
|
||||
receive the same message, except for the isolate that sent it.
|
||||
When one isolate sends a message, all other isolates will receive the same message, except for the isolate that sent it.
|
||||
|
||||
It is injected into your application's `Container` as
|
||||
`pub_sub.Client`, so you can use it as follows:
|
||||
It is injected into your application's `Container` as `pub_sub.Client`, so you can use it as follows:
|
||||
|
||||
```dart
|
||||
// Use the injected `pub_sub.Client` to send messages.
|
||||
|
@ -71,9 +68,8 @@ onGreetingChanged
|
|||
```
|
||||
|
||||
## Run-time Metadata
|
||||
At run-time, you may want to know information about the currently-running instance,
|
||||
for example, which number instance. For this, the `InstanceInfo` class is injected
|
||||
into each instance:
|
||||
|
||||
At run-time, you may want to know information about the currently-running instance, for example, which number instance. For this, the `InstanceInfo` class is injected into each instance:
|
||||
|
||||
```dart
|
||||
var instanceInfo = app.container.make<InstanceInfo>();
|
||||
|
@ -81,19 +77,20 @@ print('This is instance #${instanceInfo.id}');
|
|||
```
|
||||
|
||||
## Command-line Options
|
||||
|
||||
The `Runner` class supplies options like the following:
|
||||
|
||||
```
|
||||
Prod-MacBook-Air:production appuser$ dart example/main.dart --help
|
||||
____________ ________________________
|
||||
___ |__ | / /_ ____/__ ____/__ /
|
||||
__ /| |_ |/ /_ / __ __ __/ __ /
|
||||
_ ___ | /| / / /_/ / _ /___ _ /___
|
||||
/_/ |_/_/ |_/ ____/ /_____/ /_____/
|
||||
```bash
|
||||
appuser$ dart example/main.dart --help
|
||||
_ _ _ ____ _____ _ _____
|
||||
/ \ | \ | |/ ___| ____| | |___ /
|
||||
/ _ \ | \| | | _| _| | | |_ \
|
||||
/ ___ \| |\ | |_| | |___| |___ ___) |
|
||||
/_/ \_\_| \_|\____|_____|_____|____/
|
||||
|
||||
A batteries-included, full-featured, full-stack framework in Dart.
|
||||
|
||||
https://angel-dart.github.io
|
||||
https://angel3-framework.web.app
|
||||
|
||||
Options:
|
||||
-h, --help Print this help information.
|
||||
|
@ -117,4 +114,4 @@ Options:
|
|||
--certificate-password The PEM certificate file password.
|
||||
--key-file The PEM key file to read.
|
||||
--key-password The PEM key file password.
|
||||
```
|
||||
```
|
||||
|
|
BIN
packages/production/angel3-screenshot.png
Normal file
BIN
packages/production/angel3-screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
|
@ -8,15 +8,15 @@ void main(List<String> args) => Runner('example', configureServer).run(args);
|
|||
|
||||
Future configureServer(Angel app) async {
|
||||
// Use the injected `pub_sub.Client` to send messages.
|
||||
var client = app.container!.make<pub_sub.Client>()!;
|
||||
String? greeting = 'Hello! This is the default greeting.';
|
||||
var client = app.container?.make<pub_sub.Client>();
|
||||
var greeting = 'Hello! This is the default greeting.';
|
||||
|
||||
// We can listen for an event to perform some behavior.
|
||||
//
|
||||
// Here, we use message passing to synchronize some common state.
|
||||
var onGreetingChanged = await client.subscribe('greeting_changed');
|
||||
var onGreetingChanged = await client?.subscribe('greeting_changed');
|
||||
onGreetingChanged
|
||||
.cast<String>()
|
||||
?.cast<String>()
|
||||
.listen((newGreeting) => greeting = newGreeting);
|
||||
|
||||
// Add some routes...
|
||||
|
@ -32,8 +32,8 @@ Future configureServer(Angel app) async {
|
|||
|
||||
// This route will push a new value for `greeting`.
|
||||
app.get('/change_greeting/:newGreeting', (req, res) {
|
||||
greeting = req.params['newGreeting'] as String?;
|
||||
client.publish('greeting_changed', greeting);
|
||||
greeting = (req.params['newGreeting'] as String? ?? '');
|
||||
client?.publish('greeting_changed', greeting);
|
||||
return 'Changed greeting -> $greeting';
|
||||
});
|
||||
|
||||
|
|
|
@ -26,7 +26,26 @@ class Runner {
|
|||
Runner(this.name, this.configureServer,
|
||||
{this.reflector = const EmptyReflector()});
|
||||
|
||||
static const String asciiArt2 = '''
|
||||
|
||||
___ _ ________________ _____
|
||||
/ | / | / / ____/ ____/ / |__ /
|
||||
/ /| | / |/ / / __/ __/ / / /_ <
|
||||
/ ___ |/ /| / /_/ / /___/ /______/ /
|
||||
/_/ |_/_/ |_/\\____/_____/_____/____/
|
||||
|
||||
''';
|
||||
|
||||
static const String asciiArt = '''
|
||||
|
||||
_ _ _ ____ _____ _ _____
|
||||
/ \\ | \\ | |/ ___| ____| | |___ /
|
||||
/ _ \\ | \\| | | _| _| | | |_ \\
|
||||
/ ___ \\| |\\ | |_| | |___| |___ ___) |
|
||||
/_/ \\_\\_| \\_|\\____|_____|_____|____/
|
||||
''';
|
||||
|
||||
static const String asciiArtOld = '''
|
||||
____________ ________________________
|
||||
___ |__ | / /_ ____/__ ____/__ /
|
||||
__ /| |_ |/ /_ / __ __ __/ __ /
|
||||
|
@ -139,7 +158,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
|||
|
||||
/// Starts a number of isolates, running identical instances of an Angel application.
|
||||
Future run(List<String> args) async {
|
||||
late pub_sub.Server server;
|
||||
pub_sub.Server? server;
|
||||
|
||||
try {
|
||||
var argResults = RunnerOptions.argParser.parse(args);
|
||||
|
@ -153,11 +172,11 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
|||
}
|
||||
}
|
||||
|
||||
print(darkGray.wrap(asciiArt.trim() +
|
||||
print(darkGray.wrap(asciiArt +
|
||||
'\n\n' +
|
||||
'A batteries-included, full-featured, full-stack framework in Dart.' +
|
||||
'\n\n' +
|
||||
'https://angel-dart.github.io\n'));
|
||||
'https://angel3-framework.web.app\n'));
|
||||
|
||||
if (argResults['help'] == true) {
|
||||
stdout..writeln('Options:')..writeln(RunnerOptions.argParser.usage);
|
||||
|
@ -191,7 +210,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
|||
..writeln(red.wrap(st.toString()));
|
||||
exitCode = 1;
|
||||
} finally {
|
||||
await server.close();
|
||||
await server?.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
name: angel3_production
|
||||
version: 3.0.1
|
||||
description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel.
|
||||
homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/production
|
||||
version: 3.0.2
|
||||
description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3.
|
||||
homepage: https://angel3-framework.web.app
|
||||
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/production
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in a new issue