ledisdb/cmd/ledis-repair/main.go

42 lines
707 B
Go
Raw Normal View History

2014-06-26 07:04:54 +04:00
package main
import (
"encoding/json"
"flag"
"github.com/siddontang/ledisdb/ledis"
"github.com/siddontang/ledisdb/leveldb"
"io/ioutil"
)
var fileName = flag.String("config", "/etc/ledis.json", "ledisdb config file")
2014-06-26 07:04:54 +04:00
func main() {
flag.Parse()
2014-06-27 07:48:14 +04:00
if len(*fileName) == 0 {
println("need ledis config file")
return
}
data, err := ioutil.ReadFile(*fileName)
2014-06-26 07:04:54 +04:00
if err != nil {
println(err.Error())
return
}
var cfg ledis.Config
if err = json.Unmarshal(data, &cfg); err != nil {
println(err.Error())
return
}
if len(cfg.DataDir) == 0 {
println("must set data dir")
return
}
2014-07-23 04:30:00 +04:00
if err = leveldb.Repair(cfg.NewDBConfig()); err != nil {
2014-06-26 07:04:54 +04:00
println("repair error: ", err.Error())
}
}