2016-03-16 178 views
0

我創建了一個在本地機器上運行良好的插件stubbydb。但是,當使用jenkins在遠程服務器上運行時,出現以下錯誤。nodejs登錄到控制檯時出錯

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)] 

因此,直到jenkins工作時間運行stubbydb響應。但詹金斯的工作完成後。它停止工作。並在console.log()聲明上給出錯誤。

如果我登錄到服務器並在節點控制檯上執行console.log("something")。我沒有看到任何錯誤。此外,如果我在登錄後直接運行stubbydb而不是詹金斯。它工作正常。

可能是什麼原因?我應該避免寫入控制檯?

回答

0

我找不到任何應用程序錯誤。問題自動解決。這似乎與詹金斯工作或服務器設置。不過,我已經刪除了所有的默認console.log並根據需要進行了日誌記錄。所以如果任何人面臨同樣的問題,只需關閉日誌記錄。

0

嘗試這樣做...

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

上拋出異常的功能。我曾經遇到過這個問題,但是有另一個Node的應用。處理異常應該能夠完成這項工作。

P.S.這不是確切的解決方案,因爲您沒有提供完整的代碼。所以,只要採取這個想法,並通過您的代碼。應該幫助。

+0

富勒代碼是[here](https://github.com/NaturalIntelligence/StubbyDB/blob/master/js/stubbyDB.js) –