mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2026-10-12 02:12:31 +00:00
deprecate option 'daemonize' (#3648)
This commit is contained in:
+4
-12
@@ -144,7 +144,7 @@ func (l *labelsMap) String() string {
|
||||
}
|
||||
|
||||
func (l *labelsMap) Set(label string) error {
|
||||
for _, pair := range strings.Split(label, ",") {
|
||||
for pair := range strings.SplitSeq(label, ",") {
|
||||
split := strings.Split(pair, ":")
|
||||
if len(split) != 2 {
|
||||
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
|
||||
if err := trace.Init(filepath.Join(cConfig.ConfigPaths.DataDir, "trace")); err != nil {
|
||||
return nil, fmt.Errorf("while setting up trace directory: %w", err)
|
||||
}
|
||||
|
||||
var logLevelViaFlag bool
|
||||
|
||||
cConfig.Common.LogLevel, logLevelViaFlag = newLogLevel(cConfig.Common.LogLevel, flags)
|
||||
|
||||
if dumpFolder != "" {
|
||||
@@ -301,24 +303,14 @@ func LoadConfig(configFile string, disableAgent bool, disableAPI bool, quiet boo
|
||||
if cConfig.API != nil && cConfig.API.Server != nil {
|
||||
cConfig.API.Server.OnlineClient = nil
|
||||
}
|
||||
// if the api is disabled as well, just read file and exit, don't daemonize
|
||||
if cConfig.DisableAPI {
|
||||
cConfig.Common.Daemonize = false
|
||||
}
|
||||
|
||||
log.Infof("single file mode : log_media=%s daemonize=%t", cConfig.Common.LogMedia, cConfig.Common.Daemonize)
|
||||
log.Infof("single file mode : log_media=%s", cConfig.Common.LogMedia)
|
||||
}
|
||||
|
||||
if cConfig.Common.PidDir != "" {
|
||||
log.Warn("Deprecation warning: the pid_dir config can be safely removed and is not required")
|
||||
}
|
||||
|
||||
if cConfig.Common.Daemonize && runtime.GOOS == "windows" {
|
||||
log.Debug("Daemonization is not supported on Windows, disabling")
|
||||
|
||||
cConfig.Common.Daemonize = false
|
||||
}
|
||||
|
||||
// recap of the enabled feature flags, because logging
|
||||
// was not enabled when we set them from envvars
|
||||
if fflist := csconfig.ListFeatureFlags(); fflist != "" {
|
||||
|
||||
@@ -418,7 +418,7 @@ func Serve(cConfig *csconfig.Config, agentReady chan bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if cConfig.Common != nil && cConfig.Common.Daemonize {
|
||||
if cConfig.Common != nil && !flags.haveTimeMachine() {
|
||||
_ = csdaemon.Notify(csdaemon.Ready, log.StandardLogger())
|
||||
// wait for signals
|
||||
return HandleSignals(cConfig)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: false
|
||||
log_media: file
|
||||
log_level: info
|
||||
log_dir: C:\ProgramData\CrowdSec\log\
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: true
|
||||
log_media: file
|
||||
log_level: info
|
||||
log_dir: C:\ProgramData\CrowdSec\log\
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: true
|
||||
log_media: stdout
|
||||
log_level: info
|
||||
config_paths:
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: false
|
||||
log_media: stdout
|
||||
log_level: info
|
||||
log_dir: /var/log/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: false
|
||||
log_media: stdout
|
||||
log_level: info
|
||||
log_dir: /var/log/
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
/*daemonization/service related stuff*/
|
||||
type CommonCfg struct {
|
||||
Daemonize bool
|
||||
Daemonize string // TODO: This is just for backward compat. Remove this later
|
||||
PidDir string `yaml:"pid_dir,omitempty"` // TODO: This is just for backward compat. Remove this later
|
||||
LogMedia string `yaml:"log_media"`
|
||||
LogDir string `yaml:"log_dir,omitempty"` // if LogMedia = file
|
||||
@@ -30,6 +30,10 @@ func (c *Config) loadCommon() error {
|
||||
c.Common = &CommonCfg{}
|
||||
}
|
||||
|
||||
if c.Common.Daemonize != "" {
|
||||
log.Debug("the option 'daemonize' is deprecated and ignored")
|
||||
}
|
||||
|
||||
if c.Common.LogMedia == "" {
|
||||
c.Common.LogMedia = "stdout"
|
||||
}
|
||||
|
||||
@@ -115,9 +115,8 @@ func GetConfig() Config {
|
||||
func NewDefaultConfig() *Config {
|
||||
logLevel := log.InfoLevel
|
||||
commonCfg := CommonCfg{
|
||||
Daemonize: false,
|
||||
LogMedia: "stdout",
|
||||
LogLevel: &logLevel,
|
||||
LogMedia: "stdout",
|
||||
LogLevel: &logLevel,
|
||||
}
|
||||
prometheus := PrometheusCfg{
|
||||
Enabled: true,
|
||||
|
||||
Vendored
-1
@@ -1,5 +1,4 @@
|
||||
common:
|
||||
daemonize: false
|
||||
log_media: stdout
|
||||
log_level: info
|
||||
prometheus:
|
||||
|
||||
@@ -40,7 +40,7 @@ setup() {
|
||||
@test "the one-shot mode works" {
|
||||
rune -0 "$CROWDSEC" -dsn file://<(fake_log) -type syslog -no-api
|
||||
refute_output
|
||||
assert_stderr --partial "single file mode : log_media=stdout daemonize=false"
|
||||
assert_stderr --partial "single file mode : log_media=stdout"
|
||||
assert_stderr --regexp "Adding file .* to filelist"
|
||||
assert_stderr --regexp "reading .* at once"
|
||||
assert_stderr --partial "Ip 1.1.1.172 performed 'crowdsecurity/ssh-bf' (6 events over 0s)"
|
||||
|
||||
@@ -77,7 +77,6 @@ config_generate() {
|
||||
"${CONFIG_DIR}/notifications/"
|
||||
|
||||
yq e '
|
||||
.common.daemonize=true |
|
||||
del(.common.pid_dir) |
|
||||
.common.log_level="info" |
|
||||
.common.log_dir=strenv(LOG_DIR) |
|
||||
|
||||
Reference in New Issue
Block a user