2014-04-06 131 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

回答