2014-04-06 61 views
1

我試圖將我的應用程序的某些日誌發送到前臺時遇到問題。用node.js發送日誌到網頁

我想將特定碼頭集裝箱的所有日誌發送到網頁。我可以將它附加到控制檯中,它可以很好地工作,但我無法設法將此流發送到一個簡單的網頁,該網頁將顯示容器中正在發生的事情。

我該怎麼做?

我已經試過使用socket.io,但我總是得到一個循環JSON錯誤,並且我可以到達前端的只有一個[對象對象],沒有別的。

下面是我用附上我的容器中的函數:

docker.containers.attach(containerId, {logs: true, stream: true, stdout: true, stderr: false, tty: false}, function(err, stream){ 
    stream.pipe(process.stdout); //This shows what happens inside the container. I want to send this output to a web page 
}) 
+0

看看這個問題http://stackoverflow.com/questions/12228274/socket-io-streaming-binary-data除非你使用'base64'你不能發出二進制與socket.io但在那問題有一些很好的聯繫。 – Gntem

回答