add init redis func.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-04-22 23:01:01 +08:00
parent 9a609aa5fe
commit a8116a8ccb
2 changed files with 16 additions and 12 deletions

View File

@ -7,6 +7,6 @@ RUN mkdir -p /tmp/build
Add build.tar.gz /tmp/build/ Add build.tar.gz /tmp/build/
WORKDIR /tmp/build WORKDIR /tmp/build
RUN go get -v -d RUN go get -v -d
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w" -o bin/gorush gorush.go RUN GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o bin/gorush gorush.go
CMD tar -C bin -czf - gorush CMD tar -C bin -czf - gorush

View File

@ -44,23 +44,27 @@ func initApp() {
RushStatus.Android.PushError = 0 RushStatus.Android.PushError = 0
} }
func initRedis() {
RedisClient = redis.NewClient(&redis.Options{
Addr: PushConf.Stat.Redis.Addr,
Password: PushConf.Stat.Redis.Password,
DB: PushConf.Stat.Redis.DB,
})
RushStatus.TotalCount = getTotalCount()
RushStatus.Ios.PushSuccess = getIosSuccess()
RushStatus.Ios.PushError = getIosError()
RushStatus.Android.PushSuccess = getAndroidSuccess()
RushStatus.Android.PushError = getAndroidError()
}
// InitAppStatus for initialize app status // InitAppStatus for initialize app status
func InitAppStatus() { func InitAppStatus() {
switch PushConf.Stat.Engine { switch PushConf.Stat.Engine {
case "memory": case "memory":
initApp() initApp()
case "redis": case "redis":
RedisClient = redis.NewClient(&redis.Options{ initRedis()
Addr: PushConf.Stat.Redis.Addr,
Password: PushConf.Stat.Redis.Password,
DB: PushConf.Stat.Redis.DB,
})
RushStatus.TotalCount = getTotalCount()
RushStatus.Ios.PushSuccess = getIosSuccess()
RushStatus.Ios.PushError = getIosError()
RushStatus.Android.PushSuccess = getAndroidSuccess()
RushStatus.Android.PushError = getAndroidError()
default: default:
initApp() initApp()
} }