From eb6693a86b3caac368e5aa5829bfa892246e1d49 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 10 May 2020 18:47:46 +0800 Subject: [PATCH] Move upgrade-ttl as a sub command of ledis so that it's easier to repair the problems (#387) --- README.md | 7 +++---- cmd/ledis/main.go | 15 +++++++++------ .../main.go => cmd/repair-ttl.go | 10 +++++----- cmd/server.go | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) rename upgrade/ledis-upgrade-ttl/main.go => cmd/repair-ttl.go (88%) diff --git a/README.md b/README.md index 9a396b9..bd84ab4 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Ledisdb is a high-performance NoSQL database library and server written in [Go]( LedisDB now supports multiple different databases as backends. -### **You must run `ledis-upgrade-ttl` before using LedisDB version 0.4, I fixed a very serious bug for key expiration and TTL.** - ## Features + Rich data structure: KV, List, Hash, ZSet, Set. @@ -20,8 +18,9 @@ LedisDB now supports multiple different databases as backends. + HTTP API support, JSON/BSON/msgpack output. + Replication to guarantee data safety. + Supplies tools to load, dump, and repair database. -+ Supports cluster, use [xcodis](https://github.com/ledisdb/xcodis) -+ Authentication (though, not via http) ++ Supports cluster, use [xcodis](https://github.com/ledisdb/xcodis). ++ Authentication (though, not via http). ++ Repair integrated: You can use `ledis repair` to repair broken databases and `ledis repair-ttl` to repair a very serious bug for key expiration and TTL if you upgraded from v0.4. ## Build from source diff --git a/cmd/ledis/main.go b/cmd/ledis/main.go index 5ff764d..5983a3e 100644 --- a/cmd/ledis/main.go +++ b/cmd/ledis/main.go @@ -14,12 +14,13 @@ var ( buildTag string cmds = [][]string{ - {"server", "run ledis server"}, - {"cli", "run ledis client"}, - {"repair", "repair ledis storage directory"}, - {"dump", "create a snapshort of ledis"}, - {"load", "load data from a snapshort"}, - {"benchmark", "run the benchmarks with ledis"}, + {"server", "Run ledis server"}, + {"cli", "Run ledis client"}, + {"repair", "Repair ledis storage directory"}, + {"dump", "Create a snapshort of ledis"}, + {"load", "Load data from a snapshort"}, + {"benchmark", "Run the benchmarks with ledis"}, + {"repair-ttl", "Repair a very serious bug for key expiration and TTL before v0.4"}, } ) @@ -55,6 +56,8 @@ func main() { cmd.Cli() case "dump": cmd.Dump() + case "repair-ttl": + cmd.RepairTTL() case "help": printSubCmds() case "server": diff --git a/upgrade/ledis-upgrade-ttl/main.go b/cmd/repair-ttl.go similarity index 88% rename from upgrade/ledis-upgrade-ttl/main.go rename to cmd/repair-ttl.go index a5fc997..2dd5138 100644 --- a/upgrade/ledis-upgrade-ttl/main.go +++ b/cmd/repair-ttl.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "encoding/binary" @@ -10,11 +10,11 @@ import ( "github.com/ledisdb/ledisdb/store" ) -var configPath = flag.String("config", "", "ledisdb config file") -var dataDir = flag.String("data_dir", "", "ledisdb base data dir") -var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name") +func RepairTTL() { + var configPath = flag.String("config", "", "ledisdb config file") + var dataDir = flag.String("data_dir", "", "ledisdb base data dir") + var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name") -func main() { flag.Parse() if len(*configPath) == 0 { diff --git a/cmd/server.go b/cmd/server.go index 081394b..24139b0 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -16,8 +16,6 @@ import ( ) var addr = flag.String("addr", "", "ledisdb listen address") -var dataDir = flag.String("data_dir", "", "ledisdb base data dir") -var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name") var usePprof = flag.Bool("pprof", false, "enable pprof") var pprofPort = flag.Int("pprof_port", 6060, "pprof http port") var slaveof = flag.String("slaveof", "", "make the server a slave of another instance") @@ -28,6 +26,8 @@ var ttlCheck = flag.Int("ttl_check", 0, "TTL check interval") var databases = flag.Int("databases", 0, "ledisdb maximum database number") func Server() { + var dbName = flag.String("db_name", "", "select a db to use, it will overwrite the config's db name") + var dataDir = flag.String("data_dir", "", "ledisdb base data dir") var configFile = flag.String("config", "", "ledisdb config file") runtime.GOMAXPROCS(runtime.NumCPU())