diff --git a/cmd/dwelling-upload/main.go b/cmd/dwelling-upload/main.go index 8a83e0d..48b1372 100644 --- a/cmd/dwelling-upload/main.go +++ b/cmd/dwelling-upload/main.go @@ -2,7 +2,6 @@ package main import ( "dwelling-upload/internal/http" - "dwelling-upload/pkg/logging" "dwelling-upload/pkg/utils" "dwelling-upload/pkg/watcher" "flag" @@ -60,11 +59,14 @@ func main() { } logFilePath := path.Join(os.Getenv("LOGS_DIRECTORY"), "file.log") - logFile, err := logging.New(logFilePath) + + logFileFd, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0660) if err != nil { - log.Fatalln("file logger:", err) + log.Fatalln("failed to open file.log:", err) } - defer logFile.Close() + defer logFileFd.Close() + + logFile := log.New(logFileFd, "", log.LstdFlags) watcha, err := watcher.NewInotifyWatcher() if err != nil { @@ -108,14 +110,10 @@ func main() { doneSignal := make(chan os.Signal, 1) signal.Notify(doneSignal, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) - logReopenSignal := make(chan os.Signal, 1) - signal.Notify(logReopenSignal, syscall.SIGHUP) go func() { for { select { - case <-logReopenSignal: - logFile.Reopen(logFilePath) case <-uploadDirNotify: uploadDirSize, err = utils.DirectorySize(*uploadDir) if err != nil {