Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
115 lines (96 sloc) 2.64 KB
package main
import (
log ""
flag ""
var (
debug bool
version bool
maxDatafileSize int
bind string
dir string
logdir string
join string
consistency string
durability string
parseSnapshot string
func init() {
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [options]\n", os.Args[0])
flag.BoolVarP(&version, "version", "V", false, "display version information")
flag.BoolVarP(&debug, "debug", "D", false, "enable debug logging")
flag.IntVar(&maxDatafileSize, "max-datafile-size", 1<<20, "maximum datafile size in bytes")
flag.StringVarP(&bind, "bind", "b", ":4920", "bind/discoverable ip:port")
flag.StringVarP(&dir, "data", "d", "data", "data directory")
flag.StringVarP(&logdir, "log-dir", "l", "", "log directory. If blank it will equals --data")
flag.StringVarP(&join, "join", "j", "", "Join a cluster by providing an address")
flag.StringVar(&consistency, "consistency", "high", "Consistency (low,medium,high)")
flag.StringVar(&durability, "durability", "high", "Durability (low,medium,high)")
flag.StringVar(&parseSnapshot, "parse-snapshot", "", "Parse and output a snapshot to Redis format")
func main() {
if debug {
} else {
if version {
fmt.Printf("bitraft version %s", FullVersion())
if parseSnapshot != "" {
err := WriteRedisCommandsFromSnapshot(os.Stdout, parseSnapshot)
if err != nil {
log.Warningf("%v", err)
var lconsistency finn.Level
switch strings.ToLower(consistency) {
log.Warningf("invalid --consistency")
case "low":
lconsistency = finn.Low
case "medium", "med":
lconsistency = finn.Medium
case "high":
lconsistency = finn.High
var ldurability finn.Level
switch strings.ToLower(durability) {
log.Warningf("invalid --durability")
case "low":
ldurability = finn.Low
case "medium", "med":
ldurability = finn.Medium
case "high":
ldurability = finn.High
if logdir == "" {
logdir = dir
mustParse := func(addr string) string {
r, err := template.Parse(addr)
if err != nil {
log.WithError(err).Fatalf("error parsing addr %s: %s", addr, err)
return r
log.WithField("bind", bind).Debug("bind raw")
bind = mustParse(bind)
log.WithField("bind", bind).Debug("bind parsed")
if err := ListenAndServe(bind, join, dir, logdir, lconsistency, ldurability); err != nil {
log.Warningf("%v", err)
You can’t perform that action at this time.