startService method
void
startService()
inherited
Implementation
void startService() {
if (!(_state == ServiceState.offline || _state == ServiceState.failed)) {
throw Exception("$name Service cannot be started while $state");
}
PrecisionStopwatch p = PrecisionStopwatch.start();
_state = ServiceState.starting;
verbose("Starting $name Service");
try {
if (this is AsyncStartupTasked) {
PrecisionStopwatch px = PrecisionStopwatch.start();
verbose("Queued Startup Task: $name");
services()
.tasks
.add((this as AsyncStartupTasked).onStartupTask().then((value) {
success(
"Completed $name Startup Task in ${px.getMilliseconds()}ms");
}));
}
onStart();
_state = ServiceState.online;
} catch (e, es) {
_state = ServiceState.failed;
error("Failed to start $name Service: $e");
error(es);
}
if (_state == ServiceState.starting) {
_state = ServiceState.failed;
}
if (_state == ServiceState.failed) {
warn(
"Failed to start $name Service! It will be offline until you restart the app or the service is re-requested.");
} else {
success("Started $name Service in ${p.getMilliseconds()}ms");
}
}