Skip to content

Commit

Permalink
Use dataDir for pyroscope.log dir
Browse files Browse the repository at this point in the history
  • Loading branch information
matoval committed Jan 14, 2025
1 parent 34c9e91 commit f9b9bde
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pkg/types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type NodeCfg struct {
ReceptorKubeClientsetRateLimiter string
}

var receptorDataDir string

func (cfg NodeCfg) Init() error {
var err error
if cfg.ID == "" {
Expand All @@ -51,6 +53,8 @@ func (cfg NodeCfg) Init() error {
return fmt.Errorf("node ID \"localhost\" is reserved")
}

receptorDataDir = cfg.DataDir

netceptor.MainInstance = netceptor.New(context.Background(), cfg.ID)

if len(cfg.FirewallRules) > 0 {
Expand All @@ -74,7 +78,7 @@ func (cfg NodeCfg) Init() error {
}
}

workceptor.MainInstance, err = workceptor.New(context.Background(), netceptor.MainInstance, cfg.DataDir)
workceptor.MainInstance, err = workceptor.New(context.Background(), netceptor.MainInstance, receptorDataDir)
if err != nil {
return err
}
Expand Down Expand Up @@ -121,7 +125,14 @@ func (pyroscopeCfg ReceptorPyroscopeCfg) Init() error {
pyroscopeLogger := logrus.New()
pyroscopeLogger.SetLevel(logrus.DebugLevel)

logFile, err := os.OpenFile("/tmp/pyroscope.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o666)
if _, err := os.Stat(receptorDataDir); os.IsNotExist(err) {
err := os.MkdirAll(receptorDataDir, 0o700)
if err != nil {
fmt.Printf("error creating directory: %v", err)
}

Check warning on line 132 in pkg/types/main.go

View check run for this annotation

Codecov / codecov/patch

pkg/types/main.go#L122-L132

Added lines #L122 - L132 were not covered by tests
}

logFile, err := os.OpenFile(fmt.Sprintf("%s/pyroscope.log", receptorDataDir), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o666)
if err != nil {
pyroscopeLogger.Fatalf("Error opening log file: %v", err)
}
Expand Down

0 comments on commit f9b9bde

Please sign in to comment.