标签:prototype .net 大致 content ati res his 关闭 技术分享
beforeStartup(app, cb) before application start components callback Arguments app - application object cb - callback function afterStartup(app, cb) after application start components callback Arguments app - application object cb - callback function beforeShutdown(app, cb) before application stop components callback Arguments app - application object cb - callback function afterStartAll(app) after all applications started callback Arguments app - application object
module.exports.beforeStartup = function(app, cb) {
// do some operations before application start up
cb();
};
module.exports.afterStartup = function(app, cb) {
// do some operations after application start up
cb();
};
module.exports.beforeShutdown = function(app, cb) {
// do some operations before application shutdown down
cb();
};
module.exports.afterStartAll = function(app) {
// do some operations after all applications start up
};// components/HelloWorld.js
module.exports = function(app, opts) {
return new HelloWorld(app, opts);
};
var HelloWorld = function(app, opts) {
this.app = app;
this.interval = opts.interval | DEFAULT_INTERVAL;
};
HelloWorld.name = ‘__HelloWorld__‘;
HelloWorld.prototype.start = function(cb) {
console.log(‘Hello World Start‘);
cb();
}
HelloWorld.prototype.afterStart = function (cb) {
console.log(‘Hello World afterStart‘);
cb();
}
HelloWorld.prototype.stop = function(force, cb) {
console.log(‘Hello World stop‘);
cb();
}var helloWorld = require(‘./app/components/HelloWorld‘);
app.configure(‘production|development‘, ‘master‘, function() {
app.load(helloWorld, {interval: 5000});
});我这边是在arena服务中增加了lifecycle,同一时候加了一个组件,步骤例如以下。
标签:prototype .net 大致 content ati res his 关闭 技术分享
原文地址:http://www.cnblogs.com/yjbjingcha/p/6788774.html