跳到主要内容
CNode

http.server 捕获不到close事件

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

为毛server close时没有打印?

查看回复

回复 (9)

E
ea7son#911 年前
引用 MiguelValentine@ea7son 异常是on error

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

E
ea7son#811 年前
引用 MiguelValentine@ea7son 异常是on error

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

E
ea7son#611 年前
引用 MiguelValentine

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

M
MiguelValentine#511 年前
var server = http.createServer(app.callback());
		server.on('close',function(){
    			console.log('server closed!');
		});
server.close();
E
ea7son#411 年前
引用 MiguelValentine@ea7son 嗯,需要server.close()才行,process.exit(0)不会触发。

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

E
ea7son#211 年前
引用 MiguelValentine你ctrl+c了?

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

M
MiguelValentine#111 年前

你ctrl+c了?

参与回复

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