mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
bug fix:fix read log file oom
This commit is contained in:
@@ -34,9 +34,16 @@ func GetLocalLog(logPath string) (fileBytes []byte, err error) {
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
logBuf := make([]byte, 2048)
|
||||
n, err := f.ReadAt(logBuf, fi.Size()-int64(len(logBuf)))
|
||||
if err != nil {
|
||||
const bufLen = 2048
|
||||
logBuf := make([]byte, bufLen)
|
||||
off := int64(0)
|
||||
if fi.Size() > int64(len(logBuf)) {
|
||||
off = fi.Size() - int64(len(logBuf))
|
||||
}
|
||||
n, err := f.ReadAt(logBuf, off)
|
||||
|
||||
//到文件结尾会有EOF标识
|
||||
if err != nil && err.Error() != "EOF" {
|
||||
log.Error(err.Error())
|
||||
debug.PrintStack()
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user