My lightweight dart:io
based web server pretty much looks like this:
import 'dart:io';
void main() {
HttpServer.bind(InternetAddress.ANY_IP_V4, 80).then((server) {
server.listen((HttpRequest request) {
// ... do stuff...
request.response.write('Alright, here is your response...');
request.response.close();
});
});
print("listing....");
}
Let's launch it (on Ubuntu Server 1.04):
$ nohup dart myServer.dart &
Listening...
Everything looking good so far. I can exit my shell and it keeps serving. However, if something goes terribly wrong - e.g. an unhandled exception is thrown - the Dart process goes down.
Any recommendation how to monitor the Dart process and restart it if necessary? I guess I could write a simple script for that, just wondering if there's a better / recommended way?
(Hosting in Apache via mod_dart might be an option - feels like overkill though and current version is unstable.)