Search code examples
javagrailsgroovytail

Redirect consecutive tail output to UI


Iam new to grails .In view i have to display the consecutive tail logs from a server file. for that iam using Jsch library to ssh to a server and executing tail command tail -n 1 -f access.log At the same time i need to redirect the consecutive tail logs to UI.

So in controllert class i have created a method to read the tail output as below.But my intention is to display the live streaming in UI as well.

Here if user press the stop button isLogStreaming will be false and quit the tail operation.The streaming will have display in the UI until user press stop button.

How i can implement this in using groovy on grails


Solution

  • You can provide log streaming to UI using Server Send Events.

    Here is clear official example how to implement it: http://guides.grails.org/server-sent-events/guide/index.html