Skip to content

Commit

Permalink
windows fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Jan 26, 2024
1 parent 0df6837 commit 3a90343
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions cmd/crowdsec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ type Flags struct {
CpuProfile string
}

func (f *Flags) haveTimeMachine() bool {
return f.OneShotDSN != ""
}

type labelsMap map[string]string

func LoadBuckets(cConfig *csconfig.Config, hub *cwhub.Hub) error {
Expand Down Expand Up @@ -369,8 +373,7 @@ func main() {
defer pprof.StopCPUProfile()
}

timeMachine := flags.OneShotDSN != ""
err := StartRunSvc(timeMachine)
err := StartRunSvc()
if err != nil {
pprof.StopCPUProfile()
log.Fatal(err) //nolint:gocritic // Disable warning for the defer pprof.StopCPUProfile() call
Expand Down
4 changes: 2 additions & 2 deletions cmd/crowdsec/run_in_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/database"
)

func StartRunSvc(timeMachine bool) error {
func StartRunSvc() error {
var (
cConfig *csconfig.Config
err error
Expand All @@ -37,7 +37,7 @@ func StartRunSvc(timeMachine bool) error {
agentReady := make(chan bool, 1)

// Enable profiling early
if cConfig.Prometheus != nil && !timeMachine {
if cConfig.Prometheus != nil && !flags.haveTimeMachine() {
var dbClient *database.Client

var err error
Expand Down
6 changes: 3 additions & 3 deletions cmd/crowdsec/run_in_svc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/crowdsecurity/crowdsec/pkg/database"
)

func StartRunSvc(timeMachine bool) error {
func StartRunSvc() error {
const svcName = "CrowdSec"
const svcDescription = "Crowdsec IPS/IDS"

Expand Down Expand Up @@ -60,7 +60,7 @@ func StartRunSvc(timeMachine bool) error {
return nil
}

func WindowsRun(timeMachine bool) error {
func WindowsRun() error {
var (
cConfig *csconfig.Config
err error
Expand All @@ -77,7 +77,7 @@ func WindowsRun(timeMachine bool) error {
agentReady := make(chan bool, 1)

// Enable profiling early
if cConfig.Prometheus != nil && !timeMachine {
if cConfig.Prometheus != nil && !flags.haveTimeMachine() {
var dbClient *database.Client
var err error

Expand Down

0 comments on commit 3a90343

Please sign in to comment.