我正在运行一个node.js服务器作为客户端Javascript应用程序的后端,我们正在使用Forever来启动node.js应用程序。
在客户端代码中发现了一个错误,该错误在尝试打开文件时提供了错误的路径(因为我们当前服务器中的大小写不敏感)。错误未正确处理,这会导致node.js崩溃。发生这种情况的前几次Forever成功地重新启动了应用程序但是在反复触发错误之后,Forever将无法恢复应用程序,并且在尝试转到任何服务器页面时我们收到502错误的网关错误。
以下是未处理的错误:
Error: ENOENT, no such file or directory 'public/projects/testHoc7/hocProject121/agents/agent1/index.agent'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.editAgentXML [as edit_agent_XML] (/srv/AgentCubesOnline/project.js:699:5)
at /srv/AgentCubesOnline/project.js:313:30
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/collection/query.js:159:5
at Cursor.nextObject (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:742:5)
at commandHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:716:14)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/db.js:1847:9
at Server.Base._callHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/server.js:478:18
error: Forever detected script exited with code: 8
error: Script restart attempt #8
/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:245
throw message;
这是我们在Forever无法重启应用程序时获得的日志消息:
Error: ENOENT, no such file or directory 'public/projects/testHoc7/hocProject121/agents/agent1/index.agent'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.writeFileSync (fs.js:971:15)
at Object.editAgentXML [as edit_agent_XML] (/srv/AgentCubesOnline/project.js:699:5)
at /srv/AgentCubesOnline/project.js:313:30
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/collection/query.js:159:5
at Cursor.nextObject (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:742:5)
at commandHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/cursor.js:716:14)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/db.js:1847:9
at Server.Base._callHandler (/srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/base.js:445:41)
at /srv/AgentCubesOnline/node_modules/mongodb/lib/mongodb/connection/server.js:478:18
error: Forever detected script exited with code: 8
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/eventemitter2.js:283
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:332:26
at process._tickCallback (node.js:419:13)
我们当然会修复错误并添加正确的错误处理,但我目前更感兴趣的是找出如何防止Forever失败。什么可能导致Forever停止将node.js带回来?