create logs dir on startup
This commit is contained in:
@@ -147,6 +147,13 @@ func (s *DiskStorage[V]) AppendMutations(id uint64, msg ...proto.Message) error
|
||||
return nil
|
||||
} else {
|
||||
path := s.logPath(id)
|
||||
// Ensure the parent directory exists (e.g. first write to a new PVC mount).
|
||||
// MkdirAll is a no-op when the directory already exists, so it's safe to
|
||||
// call on every AppendMutations without extra stat overhead.
|
||||
if err := os.MkdirAll(s.path, 0755); err != nil {
|
||||
log.Printf("failed to create event log directory %s: %v", s.path, err)
|
||||
return err
|
||||
}
|
||||
fh, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
log.Printf("failed to open event log file: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user