create logs dir on startup
This commit is contained in:
+3
-1
@@ -51,7 +51,9 @@ func main() {
|
|||||||
reg := profile.NewProfileMutationRegistry()
|
reg := profile.NewProfileMutationRegistry()
|
||||||
|
|
||||||
profileDir := getEnv("PROFILE_DIR", "data/profiles")
|
profileDir := getEnv("PROFILE_DIR", "data/profiles")
|
||||||
_ = os.MkdirAll(profileDir, 0755)
|
if err := os.MkdirAll(profileDir, 0755); err != nil {
|
||||||
|
log.Printf("warning: could not create profile data directory %s: %v", profileDir, err)
|
||||||
|
}
|
||||||
diskStorage := actor.NewDiskStorage[profile.ProfileGrain](profileDir, reg)
|
diskStorage := actor.NewDiskStorage[profile.ProfileGrain](profileDir, reg)
|
||||||
|
|
||||||
poolConfig := actor.GrainPoolConfig[profile.ProfileGrain]{
|
poolConfig := actor.GrainPoolConfig[profile.ProfileGrain]{
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ func (s *DiskStorage[V]) AppendMutations(id uint64, msg ...proto.Message) error
|
|||||||
return nil
|
return nil
|
||||||
} else {
|
} else {
|
||||||
path := s.logPath(id)
|
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)
|
fh, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to open event log file: %v", err)
|
log.Printf("failed to open event log file: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user