CNode

http.server 捕获不到close事件

问答
Eea7son发布于11 年前最后回复11 年前9 回复4816 浏览0 收藏
		var server = http.createServer(app.callback());
		server.on('close',function(){
    			console.log('server closed!');
		});

为毛server close时没有打印?

查看回复

回复 (9)

M
MiguelValentine#1·11 年前

你ctrl+c了?

E
ea7son#2·11 年前
引用 MiguelValentine你ctrl+c了?

@MiguelValentine 用ws调试的,效果应该就是ctrl +c了吧?这个事件抓不到么? 自豪地采用 CNodeJS ionic

E
ea7son#4·11 年前
引用 MiguelValentine@ea7son 嗯,需要server.close()才行,process.exit(0)不会触发。

@MiguelValentine 我也试过监听这个事件,但是也抓不到 自豪地采用 CNodeJS ionic

M
MiguelValentine#5·11 年前
var server = http.createServer(app.callback());
		server.on('close',function(){
    			console.log('server closed!');
		});
server.close();
E
ea7son#6·11 年前
引用 MiguelValentine

@MiguelValentine 额,我的本意是监听server的异常退出,这样显式的调用没有实际意义哇 自豪地采用 CNodeJS ionic

E
ea7son#8·11 年前
引用 MiguelValentine@ea7son 异常是on error

@MiguelValentine process.exit()不算异常么? 自豪地采用 CNodeJS ionic

E
ea7son#9·11 年前
引用 MiguelValentine@ea7son 异常是on error

@MiguelValentine 或者说有没有事情是只要退出就能捕获的?不管是否异常 自豪地采用 CNodeJS ionic

参与回复
登录后即可参与回复。登录