2014-06-26 07:04:54 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"flag"
|
|
|
|
"github.com/siddontang/ledisdb/ledis"
|
2014-07-25 13:58:00 +04:00
|
|
|
"github.com/siddontang/ledisdb/store"
|
2014-06-26 07:04:54 +04:00
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
2014-07-02 06:11:16 +04:00
|
|
|
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-25 13:58:00 +04:00
|
|
|
if err = store.Repair(cfg.NewDBConfig()); err != nil {
|
2014-06-26 07:04:54 +04:00
|
|
|
println("repair error: ", err.Error())
|
|
|
|
}
|
|
|
|
}
|