简体   繁体   English

NodeJS SIGKILL不存在并引发错误

[英]NodeJS SIGKILL does not exists and throws error

I have implement in my node js app restart of node using terminal: 我使用终端在节点的节点js应用程序重启中实现了:

killall -9 node

i try to detect SIGKILL before node is actually killed with this code: 我尝试在此代码实际上杀死节点之前检测SIGKILL:

process.on('SIGKILL', function() {
    /* DO SOME STUFF HERE */

    process.exit()
})

but problem is that node does not recognize SIGKILL and throws an error while compiling...so my question is does anyone have idea how to detect killall -9 command in node before node app is terminated so that i can do some stuff before killing node app? 但问题是节点无法识别SIGKILL并在编译时引发错误...所以我的问题是没有人知道如何在终止节点应用程序之前检测节点中的killall -9命令,以便我可以在杀死节点之前做一些事情应用程式?

I read on node web page that SIGKILL is reserved and is not used so i need alternative way how to detect killall -9 command.... thanks 我在节点网页上阅读了SIGKILL是保留的,没有使用,所以我需要另一种方法来检测killall -9命令。

Problem solved using: 使用以下方法解决了问题:

killall -2 node

-2 define signal interrupt like Ctrl+C so node triggers SIGINT before exits because -2 simulates Ctrl+C...and voila problem solved. -2定义了像Ctrl+C这样的信号中断,因此节点退出之前会触发SIGINT,因为-2模拟了Ctrl + C ...并且解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM