NetEase / pomelo

A fast,scalable,distributed game server framework for Node.js.
http://pomelo.netease.com
MIT License
11.88k stars 2.9k forks source link

热更新支持svn #631

Closed IceFrozen closed 10 years ago

IceFrozen commented 10 years ago

热更新机制机制 有个不足 如果我服务器端用的是svn 在执行svn update 服务器handler 热更新fs.watch代码回调函数里加了 fs.watch(p, function(event, name) { console.log(event,"================="+name); if(event === 'change') { console.log(event,"++++++++++++++++++++++++"+name); handlerMap[app.serverType] = Loader.load(p, app); } });

更新servers/game/handler/backpack.js 然后提交 服务器 更新 结果出现下面的堆栈

[2014-10-24 03:25:44.063] [ERROR] console - Caught exception:

[2014-10-24 03:25:44.064] [ERROR] console - { [Error: ENOENT, no such file or directory '/root/Desktop/wuxia/app/servers/game/handler/tempfile.tmp'] errno: 34, code: 'ENOENT', path: '/root/Desktop/wuxia/app/servers/game/handler/tempfile.tmp', syscall: 'stat' } Error: ENOENT, no such file or directory '/root/Desktop/wuxia/app/servers/game/handler/tempfile.tmp' at Object.fs.statSync (fs.js:684:18) at isFile (/root/Desktop/wuxia/node_modules/pomelo-loader/lib/loader.js:113:12) at loadPath (/root/Desktop/wuxia/node_modules/pomelo-loader/lib/loader.js:74:7) at Object.module.exports.load (/root/Desktop/wuxia/node_modules/pomelo-loader/lib/loader.js:39:9) at FSWatcher. (/root/Desktop/wuxia/node_modules/pomelo/lib/common/service/handlerService.js:95:45) at FSWatcher.EventEmitter.emit (events.js:98:17) at FSEvent.FSWatcher._handle.onchange (fs.js:1039:12)

[2014-10-24 03:25:44.066] [INFO] console - change =========================tempfile.tmp

[2014-10-24 03:25:44.066] [INFO] console - change =========================tempfile.tmp

[2014-10-24 03:25:44.066] [INFO] console - change ++++++++++++++++++++++++tempfile.tmp

[2014-10-24 03:25:44.080] [INFO] console - rename =========================tempfile.tmp

[2014-10-24 03:25:44.080] [INFO] console - rename =========================tempfile.tmp

[2014-10-24 03:25:44.081] [INFO] console - rename =========================backpack.js

[2014-10-24 03:25:44.081] [INFO] console - rename =========================backpack.js

svn 更新是这样 不知道其他的是git 是什么样子

另:我如果新加 handler 用svn 更新 是不是也更新不到

cynron commented 10 years ago

其实所有这种监视文件的改动,然后重新reload这种所谓的热更新,因为具体的情况千差万别,不可能做到满足所有情况.

当确实有热更新需求时,还是建议用户根据自己的具体需求来实现,可以通过信号激发,然后实现平滑更新.