Skip to content

Commit 52ebcc3

Browse files
authored
deprecate option 'daemonize' (#3648)
1 parent 818974e commit 52ebcc3

File tree

12 files changed

+13
-25
lines changed

12 files changed

+13
-25
lines changed

cmd/crowdsec/main.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (l *labelsMap) String() string {
144144
}
145145

146146
func (l *labelsMap) Set(label string) error {
147-
for _, pair := range strings.Split(label, ",") {
147+
for pair := range strings.SplitSeq(label, ",") {
148148
split := strings.Split(pair, ":")
149149
if len(split) != 2 {
150150
return fmt.Errorf("invalid format for label '%s', must be key:value", pair)
@@ -233,7 +233,9 @@ func LoadConfig(configFile string, disableAgent bool, disableAPI bool, quiet boo
233233
if err := trace.Init(filepath.Join(cConfig.ConfigPaths.DataDir, "trace")); err != nil {
234234
return nil, fmt.Errorf("while setting up trace directory: %w", err)
235235
}
236+
236237
var logLevelViaFlag bool
238+
237239
cConfig.Common.LogLevel, logLevelViaFlag = newLogLevel(cConfig.Common.LogLevel, flags)
238240

239241
if dumpFolder != "" {
@@ -301,24 +303,14 @@ func LoadConfig(configFile string, disableAgent bool, disableAPI bool, quiet boo
301303
if cConfig.API != nil && cConfig.API.Server != nil {
302304
cConfig.API.Server.OnlineClient = nil
303305
}
304-
// if the api is disabled as well, just read file and exit, don't daemonize
305-
if cConfig.DisableAPI {
306-
cConfig.Common.Daemonize = false
307-
}
308306

309-
log.Infof("single file mode : log_media=%s daemonize=%t", cConfig.Common.LogMedia, cConfig.Common.Daemonize)
307+
log.Infof("single file mode : log_media=%s", cConfig.Common.LogMedia)
310308
}
311309

312310
if cConfig.Common.PidDir != "" {
313311
log.Warn("Deprecation warning: the pid_dir config can be safely removed and is not required")
314312
}
315313

316-
if cConfig.Common.Daemonize && runtime.GOOS == "windows" {
317-
log.Debug("Daemonization is not supported on Windows, disabling")
318-
319-
cConfig.Common.Daemonize = false
320-
}
321-
322314
// recap of the enabled feature flags, because logging
323315
// was not enabled when we set them from envvars
324316
if fflist := csconfig.ListFeatureFlags(); fflist != "" {

cmd/crowdsec/serve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func Serve(cConfig *csconfig.Config, agentReady chan bool) error {
418418
return nil
419419
}
420420

421-
if cConfig.Common != nil && cConfig.Common.Daemonize {
421+
if cConfig.Common != nil && !flags.haveTimeMachine() {
422422
_ = csdaemon.Notify(csdaemon.Ready, log.StandardLogger())
423423
// wait for signals
424424
return HandleSignals(cConfig)

config/config_win.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: false
32
log_media: file
43
log_level: info
54
log_dir: C:\ProgramData\CrowdSec\log\

config/config_win_no_lapi.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: true
32
log_media: file
43
log_level: info
54
log_dir: C:\ProgramData\CrowdSec\log\

config/dev.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: true
32
log_media: stdout
43
log_level: info
54
config_paths:

config/user.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: false
32
log_media: stdout
43
log_level: info
54
log_dir: /var/log/

docker/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: false
32
log_media: stdout
43
log_level: info
54
log_dir: /var/log/

pkg/csconfig/common.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
/*daemonization/service related stuff*/
1111
type CommonCfg struct {
12-
Daemonize bool
12+
Daemonize string // TODO: This is just for backward compat. Remove this later
1313
PidDir string `yaml:"pid_dir,omitempty"` // TODO: This is just for backward compat. Remove this later
1414
LogMedia string `yaml:"log_media"`
1515
LogDir string `yaml:"log_dir,omitempty"` // if LogMedia = file
@@ -30,6 +30,10 @@ func (c *Config) loadCommon() error {
3030
c.Common = &CommonCfg{}
3131
}
3232

33+
if c.Common.Daemonize != "" {
34+
log.Debug("the option 'daemonize' is deprecated and ignored")
35+
}
36+
3337
if c.Common.LogMedia == "" {
3438
c.Common.LogMedia = "stdout"
3539
}

pkg/csconfig/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ func GetConfig() Config {
115115
func NewDefaultConfig() *Config {
116116
logLevel := log.InfoLevel
117117
commonCfg := CommonCfg{
118-
Daemonize: false,
119-
LogMedia: "stdout",
120-
LogLevel: &logLevel,
118+
LogMedia: "stdout",
119+
LogLevel: &logLevel,
121120
}
122121
prometheus := PrometheusCfg{
123122
Enabled: true,

pkg/csconfig/testdata/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
common:
2-
daemonize: false
32
log_media: stdout
43
log_level: info
54
prometheus:

0 commit comments

Comments
 (0)