honeycomb-server
honeycomb-server copied to clipboard
upgrade app start interface
通过重写 run.js中的 net.Server.prototype.listen()
, 可以无感知的替换监听端口为domain-sock,
再通过process.honeycomb提供接口启动,看起来可以做到比现在的app挂载方式更优雅
file: run.js
net.Server.prototype.listen = () => {
};
process.honeycomb = {
targetSock,
config,
ready: function (config) {
}
};
app的编写就简化为:
file: app.js
// app 都有自己监听成功的事件,在成功的callback里调用ready
app.listen(()= >{
process.honeycomb.ready({
serverName: ''
router: '',
....
});
});
// app获取honeycomb的配置信息
process.honeycomb.config