Browse Source

disable flush only if single file is enable

Thibault bui Koechlin 5 years ago
parent
commit
6de941da8d
1 changed files with 6 additions and 2 deletions
  1. 6 2
      cmd/crowdsec/main.go

+ 6 - 2
cmd/crowdsec/main.go

@@ -151,7 +151,12 @@ func LoadOutputs(cConfig *csconfig.CrowdSec) error {
 		return fmt.Errorf("Failed to load output profiles : %v", err)
 		return fmt.Errorf("Failed to load output profiles : %v", err)
 	}
 	}
 
 
-	OutputRunner, err = outputs.NewOutput(cConfig.OutputConfig, cConfig.Daemonize)
+	//If the user is providing a single file (ie forensic mode), don't flush expired records
+	if cConfig.SingleFile != "" {
+		log.Infof("forensic mode, disable flush")
+		cConfig.OutputConfig.Flush = false
+	}
+	OutputRunner, err = outputs.NewOutput(cConfig.OutputConfig)
 	if err != nil {
 	if err != nil {
 		return fmt.Errorf("output plugins initialization error : %s", err.Error())
 		return fmt.Errorf("output plugins initialization error : %s", err.Error())
 	}
 	}
@@ -280,7 +285,6 @@ func main() {
 
 
 	if err := LoadBuckets(cConfig); err != nil {
 	if err := LoadBuckets(cConfig); err != nil {
 		log.Fatalf("Failed to load scenarios: %s", err)
 		log.Fatalf("Failed to load scenarios: %s", err)
-
 	}
 	}
 
 
 	if err := LoadOutputs(cConfig); err != nil {
 	if err := LoadOutputs(cConfig); err != nil {