将连续的尾部输出重定向到 UI

Redirect consecutive tail output to UI

我是 grails 的新手。看来我必须显示来自服务器文件的连续尾日志。 为此,iam 使用 Jsch 库通过 ssh 连接到服务器并执行 tail 命令 tail -n 1 -f access.log 同时我需要将连续的尾日志重定向到 UI.

所以在 controllert class 中我创建了一个方法来读取尾部输出 below.But 我的意图是 也显示 UI 中的直播。

如果用户按下停止按钮,isLogStreaming 将为 false 并退出 tail operation.The 流 将在 UI 中显示,直到用户按下停止按钮。

我如何在 grails

上使用 groovy 来实现这个

您可以使用 服务器发送事件 向 UI 提供日志流。

这里有一个清晰的官方示例如何实现它:http://guides.grails.org/server-sent-events/guide/index.html