使用node-java软件包时,nodemon不会重新启动服务器 [英] nodemon is not restarting the server when using node-java package
问题描述
使用 node-java 软件包时,文件更改时 nodemon不会重新启动.如果我删除node-java 软件包,则 nodemon将在文件更改时重新启动.
When using node-java package, nodemon doesn't restart when the files change. If I remove node-java package then nodemon will restart when there are file changes.
在服务器中使用node-java软件包时,即使手动重启(rs)也不起作用.以下是行为.
Even the manual restart (rs) is not working when using node-java package in server. Following is the behavior.
alon
甚至抛出以下内容:
events.js:85
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at exports._errnoException (util.js:746:11)
at Server._listen2 (net.js:1156:14)
at listen (net.js:1182:10)
at Server.listen (net.js:1267:5)
由于端口4000在服务器中仅使用了一次,在其他任何地方都没有使用,因此它的行为很奇怪.
Since the port 4000 is being used only once in server and no where else, its behaving weird.
推荐答案
似乎node-java在接收到SIGUSR2
信号时以某种方式神奇地替代"了正在发生的事情.在这种情况下,重新启动应用程序的SIGUSR2
信号(由nodemon
使用)可能无法终止应用程序.
It seems that node-java somehow magically 'overrides' what's happening when receiving SIGUSR2
signal. In such a case, the SIGUSR2
signal (used by nodemon
) to restart the app may fail terminating the app.
(快速)修复:
在节点java搞清您的SIGUSR2
处理机制之后,添加以下代码段:
after the node-java has screwed your SIGUSR2
handling mechanism, add the following snippet of code:
process.once('SIGUSR2', function() {
process.kill(process.pid, 'SIGUSR2')
})
请注意,您必须在node-java
(或使用它的东西,在我的情况下为node-tika
)执行工作"之后(在我的情况下,需要node-tika
之后立即执行此操作).
note that you must do this AFTER the node-java
(or something which uses it, in my case it is node-tika
) does its 'job' (in my case, immediately after requiring node-tika
).
说实话,我对此的理解很少,为什么会奏效,如果有人能对此提供更多的信息,我会感到很高兴.
To be honest, I have only very little understanding, why this works and I'll be glad if someone can shed more light on this.
这篇关于使用node-java软件包时,nodemon不会重新启动服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!