From e2fd36195d04ead72c5be79178432ef0cf56f8e9 Mon Sep 17 00:00:00 2001 From: "qcqcqc@bash-agent-dev" <1220204124@zust.edu.cn> Date: Fri, 25 Apr 2025 16:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6bug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-service/cmd/main.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend-service/cmd/main.go b/backend-service/cmd/main.go index 21af4f6..be3d683 100644 --- a/backend-service/cmd/main.go +++ b/backend-service/cmd/main.go @@ -320,7 +320,19 @@ func startDaemonProcess() error { } goTimeFormat := formatGoTime(constants.LogNameFormate) logFileName := time.Now().Format(goTimeFormat) - logFilePath := filepath.Join(constants.LogFilePath, logFileName) + // logFilePath := filepath.Join(constants.LogFilePath, logFileName) + var logFilePath string + if isDebug() { + logFilePath = filepath.Join(constants.LogFilePath, logFileName) + } else { + exePath, err := os.Executable() + if err != nil { + logger.Error("Error getting executable path: %v", err) + return err + } + exeDir := filepath.Dir(exePath) + logFilePath = filepath.Join(exeDir, constants.LogFilePath, logFileName) + } logFile, err := os.OpenFile(logFilePath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, constants.LogFileMode) if err != nil { return fmt.Errorf("open log file: %w", err)