无法杀死NodeJS应用 [英] Can't kill NodeJS app

查看:87
本文介绍了无法杀死NodeJS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一天,我的应用决定一无所有.

One day, out of nothing, my app decided not to die.

在我检查端口时按ctrl + c后,它仍然存在,不仅在我的机器上,而且在PM2管理的服务器上,因此我需要每次都去那里并手动杀死该进程.我试图在代码中查找问题,但当我无法找到代码时,这仅仅是依赖关系故障之一,很快就会有修复.有点烦人,但是我可以使用kill -9 PID终止进程,并且我承担了前端所执行的大部分任务,因此这并不是一个大问题.今天,一个多星期后,问题仍然存在. 我回溯到历史,选择了几周前所做的提交,所有工作均正常进行,将NodeJS从5.1.0切换到4.2.1,清除了npm缓存,重新安装了所有依赖项,但我仍然看到了问题. 我正在使用LoopbackJS,但通常我只是使用"node server/server.js"启动应用程序,然后发生上述问题,但是如果我使用"slc run",然后尝试使用ctrl + c终止该应用程序只是永远挂着,我的意思是我可以按ctrl + c任意次,它仍在控制台前台运行.

After pressing ctrl + c when I inspect port it's still there and not only on my machine but also on server that is managed by PM2 so I need to go there each time and kill the process by hand. I tried to look for issues in my code and when I couldn't I just though that it's simply one of the dependencies fault and soon there will be a fix. It was slightly annoying but I could kill the process with kill -9 PID and I had most of the tasks I had on front-end side so it wasn't that big issue. Today, more than a week later problem it's still here. I went back in history, picked a commit that I made weeks ago, where everything worked perfectly fine, switched NodeJS from 5.1.0 to 4.2.1, cleared npm cache, reinstalled all dependencies and I still see the problem. I'm using LoopbackJS, but normally I start the app simply with "node server/server.js" and then the problem described above happens, but if I use "slc run" and then try to kill the app with ctrl + c it just hangs forever, I mean I can press ctrl+c as many times as I want and it's still running in console foreground.

如果我没有按Ctrl + C组合键,而是杀死了控制台中的选项卡,则应用程序死掉没有问题.

If instead of pressing ctrl+c I kill the tab in console, app dies without problems.

这是我在运行"lsof -i tcp:4000"后应该看到的应用程序已经死了但不是的情况.

This is what I see after running "lsof -i tcp:4000" when the app is supposed to be dead but is not

使用Strongloop流程管理器运行和终止它-slc start/slc stop可以正常工作,但是在开发过程中使用正常方式运行Node.js应用程序(node server.js)会更方便,并且不会改变存在某些事实的事实问题,最好不要将其隐藏在地毯下.

Running and killing it with Strongloop process manager - slc start/slc stop works fine but it would be more convenient to use normal way of running NodeJS app (node server.js) during development and it doesn't change the fact that there is some issue and it would be better to not hide it under the carpet.

推荐答案

出于愤怒,我将应用程序剥离了一些最基本的元素.逐个文件,我找到了答案. 罪魁祸首是phantomJS- https://github.com/sgentle/phantomjs-node . PATCH版本0.8.2引入了此错误. Fix是在一个月前创建的,一周前已合并,但尚未在npm上发布.

Out of anger I stripped out my app to the most basic elements. File by file, piece by piece and I found the answer. The culprit was phantomJS - https://github.com/sgentle/phantomjs-node. PATCH version 0.8.2 introduced this bug. Fix was created almost a month ago, merged a week ago but not published on npm yet.

这篇关于无法杀死NodeJS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆