add http.profile = -1 to exit RedisShake once finish restoring RDB

v4
vinllen 5 years ago
parent b1abb9b27f
commit b276dc44f6
  1. 12
      conf/redis-shake.conf
  2. 12
      src/redis-shake/main/main.go
  3. 3
      src/redis-shake/restore.go

@ -12,9 +12,11 @@ log.level = info
# 注意这个是目录,真正的pid是`{pid_path}/{id}.pid` # 注意这个是目录,真正的pid是`{pid_path}/{id}.pid`
pid_path = pid_path =
# pprof port # pprof port.
system_profile = 9310 system_profile = 9310
# restful port,查看metric端口 # restful port, set -1 means disable, in `restore` mode RedisShake will exit once finish restoring RDB only if this value
# is -1, otherwise, it'll wait forever.
# restful port,查看metric端口, -1表示不启用,如果是`restore`模式,只有设置为-1才会在完成RDB恢复后退出,否则会一直block。
http_profile = 9320 http_profile = 9320
# runtime.GOMAXPROCS, 0 means use cpu core number: runtime.NumCPU() # runtime.GOMAXPROCS, 0 means use cpu core number: runtime.NumCPU()
@ -137,9 +139,11 @@ filter.slot =
filter.lua = false filter.lua = false
# big key threshold, the default is 500 * 1024 * 1024 bytes. If the value is bigger than # big key threshold, the default is 500 * 1024 * 1024 bytes. If the value is bigger than
# this given value, all the field will be spilt and write into the target in order. # this given value, all the field will be spilt and write into the target in order. If
# the target Redis type is Codis, this should be set to 1, please checkout FAQ to find
# the reason.
# 正常key如果不大,那么都是直接调用restore写入到目的端,如果key对应的value字节超过了给定 # 正常key如果不大,那么都是直接调用restore写入到目的端,如果key对应的value字节超过了给定
# 的值,那么会分批依次一个一个写入。 # 的值,那么会分批依次一个一个写入。如果目的端是Codis,这个需要置为1,具体原因请查看FAQ。
big_key_threshold = 524288000 big_key_threshold = 524288000
# use psync command. # use psync command.

@ -34,8 +34,8 @@ import (
type Exit struct{ Code int } type Exit struct{ Code int }
const ( const (
defaultHttpPort = 20881 defaultHttpPort = 9320
defaultSystemPort = 20882 defaultSystemPort = 9310
defaultSenderSize = 65535 defaultSenderSize = 65535
defaultSenderCount = 1024 defaultSenderCount = 1024
) )
@ -150,6 +150,10 @@ func initFreeOS() {
} }
func startHttpServer() { func startHttpServer() {
if conf.Options.HttpProfile == -1 {
return
}
utils.InitHttpApi(conf.Options.HttpProfile) utils.InitHttpApi(conf.Options.HttpProfile)
utils.HttpApi.RegisterAPI("/conf", nimo.HttpGet, func([]byte) interface{} { utils.HttpApi.RegisterAPI("/conf", nimo.HttpGet, func([]byte) interface{} {
return &conf.Options return &conf.Options
@ -360,11 +364,13 @@ func sanitizeOptions(tp string) error {
} }
} }
if conf.Options.HttpProfile < 0 || conf.Options.HttpProfile > 65535 { if conf.Options.HttpProfile < -1 || conf.Options.HttpProfile > 65535 {
return fmt.Errorf("HttpProfile[%v] should in [0, 65535]", conf.Options.HttpProfile) return fmt.Errorf("HttpProfile[%v] should in [0, 65535]", conf.Options.HttpProfile)
} else if conf.Options.HttpProfile == 0 { } else if conf.Options.HttpProfile == 0 {
// set to default when not set // set to default when not set
conf.Options.HttpProfile = defaultHttpPort conf.Options.HttpProfile = defaultHttpPort
} else if conf.Options.HttpProfile == -1 {
log.Info("http_profile is disable")
} }
if conf.Options.SystemProfile < 0 || conf.Options.SystemProfile > 65535 { if conf.Options.SystemProfile < 0 || conf.Options.SystemProfile > 65535 {

@ -87,7 +87,8 @@ func (cmd *CmdRestore) Main() {
wg.Wait() wg.Wait()
close(restoreChan) close(restoreChan)
if conf.Options.HttpProfile > 0 { log.Infof("restore from '%s' to '%s' done", conf.Options.RdbInput, conf.Options.TargetAddressList)
if conf.Options.HttpProfile != -1 {
//fake status if set http_port. and wait forever //fake status if set http_port. and wait forever
base.Status = "incr" base.Status = "incr"
log.Infof("Enabled http stats, set status (incr), and wait forever.") log.Infof("Enabled http stats, set status (incr), and wait forever.")

Loading…
Cancel
Save