2020-05-09 16:30:50 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2020-05-10 13:17:39 +03:00
|
|
|
_ "net/http/pprof"
|
|
|
|
|
2023-02-15 10:41:45 +03:00
|
|
|
"git.internal/re/ledisdb/cmd"
|
2020-05-09 16:30:50 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2020-05-10 08:32:35 +03:00
|
|
|
version = "dev"
|
|
|
|
buildTag string
|
|
|
|
|
2020-05-09 16:30:50 +03:00
|
|
|
cmds = [][]string{
|
2020-05-10 13:47:46 +03:00
|
|
|
{"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"},
|
2020-05-09 16:30:50 +03:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func printSubCmds() {
|
|
|
|
for _, cmd := range cmds {
|
|
|
|
printCmd(cmd[0], cmd[1])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func printCmd(cmd, description string) {
|
|
|
|
fmt.Printf("%s\t- %s\n", cmd, description)
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2020-05-10 08:32:35 +03:00
|
|
|
fmt.Printf("Version %s", version)
|
|
|
|
if len(buildTag) > 0 {
|
|
|
|
fmt.Printf(" with tag %s", buildTag)
|
|
|
|
}
|
|
|
|
fmt.Println()
|
2020-05-09 16:30:50 +03:00
|
|
|
var subCmd string
|
|
|
|
if len(os.Args) == 1 {
|
|
|
|
subCmd = "server"
|
|
|
|
} else {
|
|
|
|
subCmd = os.Args[1]
|
|
|
|
}
|
|
|
|
|
|
|
|
switch subCmd {
|
|
|
|
case "repair":
|
2020-05-10 13:17:39 +03:00
|
|
|
cmd.Repair()
|
2020-05-09 16:30:50 +03:00
|
|
|
case "benchmark":
|
2020-05-10 13:17:39 +03:00
|
|
|
cmd.Benchmark()
|
2020-05-09 16:30:50 +03:00
|
|
|
case "cli":
|
2020-05-10 13:17:39 +03:00
|
|
|
cmd.Cli()
|
2020-05-09 16:30:50 +03:00
|
|
|
case "dump":
|
2020-05-10 13:17:39 +03:00
|
|
|
cmd.Dump()
|
2020-05-10 13:47:46 +03:00
|
|
|
case "repair-ttl":
|
|
|
|
cmd.RepairTTL()
|
2020-05-09 16:30:50 +03:00
|
|
|
case "help":
|
|
|
|
printSubCmds()
|
|
|
|
case "server":
|
|
|
|
fallthrough
|
|
|
|
default:
|
2020-05-10 13:17:39 +03:00
|
|
|
cmd.Server()
|
2020-05-09 16:30:50 +03:00
|
|
|
}
|
|
|
|
}
|