feat(controller): added copy by server only currently
This commit is contained in:
21
controller/stream_output.go
Normal file
21
controller/stream_output.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
socketio "github.com/googollee/go-socket.io"
|
||||
)
|
||||
|
||||
// streamOutput reads io.Reader line by line and broadcasts
|
||||
func streamOutput(r io.Reader, server *socketio.Server, room string) {
|
||||
scanner := bufio.NewScanner(r)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
server.BroadcastToRoom("/", room, "buildlogs", line)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
server.BroadcastToRoom("/", room, "buildlogs", fmt.Sprintf("❌ Log stream error: %v", err))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user