Name: ready-callback
Owner: node_modules
Description: Launch server after all async task ready
Created: 2015-02-03 17:20:39.0
Updated: 2018-05-22 03:00:54.0
Pushed: 2017-05-24 18:09:56.0
Size: 55
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Launch server after all async task ready
m install ready-callback
Note: ready-callback is using class
, so you should use node>=2
koa = require('koa');
ready = require('ready-callback')();
app = koa();
y.mixin(app);
egister a service
done = app.readyCallback('service');
iceLaunch(done);
allback will be fired after all service launched
ready(function() {
p.listen();
If task is called with error, error
event will be emit, ready
will never be called.
egister a service that will emit error
done = app.readyCallback('service');
iceLaunch(function(err) {
ne(err);
isten error event
on('error', function(err) {
catch error
If you set a task weak dependency, task will be done without emit error
.
done = app.readyCallback('service', {isWeakDep: true});
iceLaunch(function(err) {
ne(err);
ill be ready
ready(function() {
p.listen();
on('error', function(err) {
never be called
You can also set for all ready-callback
ready = require('ready-callback')({isWeakDep: true});
You can get status every callback end.
on('ready_stat', function(data) {
nsole.log(data.id); // id of the ended task
nsole.log(data.remain); // tasks waiting to be ended
You can set timeout when a task run a long time.
ready = require('ready-callback')({timeout: 1000});
y.mixin(app);
on('ready_timeout', function(id) {
this will be called after 1s that `service` task don't complete
done = app.readyCallback('service');
iceLaunch(function() {
run a long time
ne();
You can also set timeout for every task
y.mixin(app);
on('ready_timeout', function(id) {
this will be called after 1s that `service` task don't complete
done = app.readyCallback('service1', {timeout: 1000});
iceLaunch(done);
Copyright (c) 2015 popomore. Licensed under the MIT license.