Files
runtime/apps/daemon/internal/util/log_reader.go
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

39 lines
675 B
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package util
import (
"bufio"
"context"
"io"
"time"
)
func ReadLog(ctx context.Context, logReader io.Reader, follow bool, c chan []byte, errChan chan error) {
reader := bufio.NewReader(logReader)
for {
select {
case <-ctx.Done():
return
default:
bytes := make([]byte, 1024)
_, err := reader.Read(bytes)
if err != nil {
if err != io.EOF {
errChan <- err
return
} else if !follow {
errChan <- io.EOF
return
}
// Sleep for a short time to avoid busy-waiting
time.Sleep(20 * time.Millisecond)
continue
}
c <- bytes
}
}
}