로그파일에 호스트이름 추가

This commit is contained in:
2024-06-05 17:26:17 +09:00
parent 4e928f3426
commit dfcb78b70c

View File

@ -93,7 +93,8 @@ func zipLogFiles(storageRoot string, req *shared.UploadRequest) (string, []strin
}
root = path.Join(root, path.Dir(req.Filter))
zipFileName := path.Join(os.TempDir(), path.Base(filepath.ToSlash(matches[0]))) + ".zip"
hostname, _ := os.Hostname()
zipFileName := path.Join(os.TempDir(), hostname+"_"+path.Base(filepath.ToSlash(matches[0]))) + ".zip"
os.Remove(zipFileName)
f, err := os.OpenFile(zipFileName, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600)
@ -537,12 +538,19 @@ func (hc *houstonClient) uploadFiles(req *shared.UploadRequest) error {
if err == nil && len(zipFile) > 0 && len(srcFiles) > 0 {
if err = hc.uploadZipLogFile(zipFile, child.name, child.version); err == nil {
// 마지막거 빼고 삭제
if req.DeleteAfterUploaded == "true" {
for i := 0; i < len(srcFiles)-1; i++ {
os.Remove(srcFiles[i])
}
} else {
sort.StringSlice(srcFiles).Sort()
for i := 0; i < len(srcFiles)-1; i++ {
if len(srcFiles[i]) > 0 {
os.Remove(srcFiles[i])
}
}
}
} else {
logger.Println("uploadZipLogFile failed :", err)
}