shutdown

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

shutdown

shutdown #
Helps you release system or shared resources during unexpected application shutdown.
Usage #
A simple usage example:
import 'dart:async';

import 'package:shutdown/shutdown.dart' as shutdown;

Future main() async {
shutdown.triggerOnSigInt();
shutdown.triggerOnSigHup();

final db = await _acquireDB();
shutdown.addHandler(() async => db.close());

// [do your stuff]

// call it at the end, this is a successful exit
await shutdown.shutdown();
}

Future _acquireDB() async => null; // TODO: implement
copied to clipboard
Tip #
Combine this library with package:stack_trace:
import 'package:shutdown/shutdown.dart' as shutdown;
import 'package:stack_trace/stack_trace.dart';

Future main() async {
shutdown.triggerOnSigInt();
shutdown.triggerOnSigHup();
return Chain.capture(() async {
// TODO: initialize, register shutdown handlers
// do your stuff
await shutdown.shutdown();
}, onError: (error, Chain chain) async {
// TODO: report/log error and stack
await shutdown.shutdown(exitCode: -1);
});
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator