简体   繁体   English

登录到控制台时出现nodejs错误

[英]nodejs error on logging to console

I have created a plugin stubbydb that is running fine on local machine. 我创建了一个插件stubbydb ,该插件可以在本地计算机上正常运行。 But while running on a remote server using jenkins, I am getting following error. 但是,在使用jenkins在远程服务器上运行时,出现以下错误。

2016-03-16T10:58:10.745Z - error: uncaughtException: write EPIPE date=Wed Mar 16 2016 10:58:10 GMT+0000 (GMT), pid=23729, uid=501, gid=500, cwd=/home/deployment, execPath=/usr/local/node/node-v5.2.0/bin/node, version=v5.2.0, argv=[/usr/local/node/node-v5.2.0/bin/node, /usr/local/node/node-default/bin/stubbydb, -d, /tmp/soa-simulator, -p, 7777, -s, /tmp/soa-simulator/], rss=22597632, heapTotal=12671264, heapUsed=8094384, loadavg=[1.7158203125, 0.68505859375, 0.27392578125], uptime=5615485, trace=[column=11, file=util.js, function=Object.exports._errnoException, line=856, method=exports._errnoException, native=false, column=20, file=util.js, function=exports._exceptionWithHostPort, line=879, method=_exceptionWithHostPort, native=false, column=14, file=net.js, function=WriteWrap.afterWrite, line=764, method=afterWrite, native=false], stack=[Error: write EPIPE,     at Object.exports._errnoException (util.js:856:11),     at exports._exceptionWithHostPort (util.js:879:20),     at WriteWrap.afterWrite (net.js:764:14)]

2016-03-16T10:58:36.696Z - error: uncaughtException: This socket is closed. date=Wed Mar 16 2016 10:58:36 GMT+0000 (GMT), pid=23729, uid=501, gid=500, cwd=/home/deployment, execPath=/usr/local/node/node-v5.2.0/bin/node, version=v5.2.0, argv=[/usr/local/node/node-v5.2.0/bin/node, /usr/local/node/node-default/bin/stubbydb, -d, /tmp/soa-simulator, -p, 7777, -s, /tmp/soa-simulator/], rss=25243648, heapTotal=12671264, heapUsed=8775480, loadavg=[1.443359375, 0.7080078125, 0.291015625], uptime=5615511, trace=[column=19, file=net.js, function=Socket._writeGeneric, line=641, method=_writeGeneric, native=false, column=8, file=net.js, function=Socket._write, line=695, method=_write, native=false, column=12, file=_stream_writable.js, function=doWrite, line=293, method=null, native=false, column=5, file=_stream_writable.js, function=writeOrBuffer, line=279, method=null, native=false, column=11, file=_stream_writable.js, function=Socket.Writable.write, line=208, method=Writable.write, native=false, column=40, file=net.js, function=Socket.write, line=619, method=write, native=false, column=16, file=console.js, function=Console.log, line=37, method=log, native=false, column=12, file=/usr/local/node/node-v5.2.0/lib/node_modules/stubby-db/js/stubbyDB.js, function=, line=29, method=null, native=false, column=13, file=events.js, function=emitNone, line=68, method=null, native=false, column=7, file=events.js, function=IncomingMessage.emit, line=167, method=emit, native=false], stack=[Error: This socket is closed.,     at Socket._writeGeneric (net.js:641:19),     at Socket._write (net.js:695:8),     at doWrite (_stream_writable.js:293:12),     at writeOrBuffer (_stream_writable.js:279:5),     at Socket.Writable.write (_stream_writable.js:208:11),     at Socket.write (net.js:619:40),     at Console.log (console.js:37:16),     at IncomingMessage.<anonymous> (/usr/local/node/node-v5.2.0/lib/node_modules/stubby-db/js/stubbyDB.js:29:12),     at emitNone (events.js:68:13),     at IncomingMessage.emit (events.js:167:7)]

So till the time jenkins job is running stubbydb responses. 因此,直到jenkins作业运行stubbydb响应为止。 But as soon as jenkins job is completed. 但是詹金斯的工作一旦完成。 It stopped working. 它停止工作了。 And Gives error on console.log() statement. 并在console.log()语句中给出错误。

If I login to the server and do console.log("something") on node console. 如果我登录到服务器并在节点控制台上执行console.log("something") I see no error. 我没有看到错误。 Moreover, if I run stubbydb directly there after login instead of jenkins. 而且,如果我在登录后直接在其中运行stubbydb而不是jenkins。 It works fine. 工作正常。

What can be the reason? 可能是什么原因? Should I avoid writing to console? 我应该避免编写控制台吗?

Try doing this ... 尝试这样做...

FunctionThrowingException().on("error", function(){
       //Handle exception here
});

on the function that is throwing the exception. 在引发异常的函数上。 I had this issue once, but with another application of Node. 我曾经遇到过这个问题,但是有Node的另一个应用程序。 Handling the exception should do the job. 处理异常应该可以完成工作。

PS This is not the exact solution, as you have not provided the full code. PS这不是确切的解决方案,因为您没有提供完整的代码。 So, just take this idea and go through your code. 因此,只需采用这个想法并遍历您的代码即可。 Should Help. 应该有所帮助。

I couldn't find anything wrong with the application. 我找不到该应用程序有什么问题。 The problem is automatically solved. 该问题会自动解决。 It seems to be with jenkins job or server setup. 它似乎与jenkins作业或服务器设置有关。 However I have removed all default console.log and made logging on demand. 但是,我删除了所有默认的console.log并按需进行日志记录。 So if anyone face the same issue, just switch off the logging. 因此,如果有人遇到相同的问题,只需关闭日志记录。

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

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