bfx-facs-base (英语)
靴子钩
有些设施需要特别的设置,然后才开始建造其他设施。 默认, bfx-facs-grc,宣布开始向葡萄网络服务 晚于别法克.
要在其它 faces 启动前运行特殊设置或清理任务, 请使用 start
选项 :
const opts = {
start: (inst, cb) => {
console.log(inst.db) // do async stuff here
cb(null)
}
}
this.setInitFacs([
['fac', 'bfx-facs-db-mongo', 'm0', 'm0', opts]
])
示例
在服务启动时, 这将打印 :
bfx-facs-first start hook
bfx-facs-second start hook
start0 executed
class WrkUtilNetApi extends WrkApi {
init () {
super.init()
this.setInitFacs([
['fac', 'bfx-facs-first', 'm0', 'm0', {
start: (inst, cb) => {
console.log('bfx-facs-first start hook')
cb(null)
}
}, 0], // prio: 0 (default)
['fac', 'bfx-facs-second', 'm0', 'm0', {
start: (inst, cb) => {
console.log('bfx-facs-second start hook')
cb(null)
}
}, 1], // prio 1
])
}
_start0 (cb) {
console.log('start0 executed')
cb(null)
}
}