From 3d806ad17989e92bcb4dfbe6782db73eac40cd10 Mon Sep 17 00:00:00 2001 From: siddontang Date: Sat, 21 Mar 2015 20:31:43 +0800 Subject: [PATCH] adjust flag handling --- cmd/ledis-server/main.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/ledis-server/main.go b/cmd/ledis-server/main.go index cdf4286..7987733 100644 --- a/cmd/ledis-server/main.go +++ b/cmd/ledis-server/main.go @@ -64,23 +64,23 @@ func main() { cfg.Databases = *databases } + // check bool flag, use it. + for _, arg := range os.Args { + arg := strings.ToLower(arg) + switch arg { + case "-rpl", "-rpl=true", "-rpl=false": + cfg.UseReplication = *rpl + case "-readonly", "-readonly=true", "-readonly=false": + cfg.Readonly = *readonly + case "-rpl_sync", "-rpl_sync=true", "-rpl_sync=false": + cfg.Replication.Sync = *rplSync + } + } + if len(*slaveof) > 0 { cfg.SlaveOf = *slaveof cfg.Readonly = true cfg.UseReplication = true - } else { - cfg.Readonly = *readonly - - // if rpl in command flag, use it. - for _, arg := range os.Args { - arg := strings.ToLower(arg) - if arg == "-rpl" || arg == "-rpl=true" || arg == "-rpl=false" { - cfg.UseReplication = *rpl - break - } - } - - cfg.Replication.Sync = *rplSync } if *ttlCheck > 0 {