mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
- 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
39 lines
675 B
Go
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
|
|
}
|
|
}
|
|
}
|