先提交一版

master
dian.chen 1 year ago
parent 74ec4b05a3
commit 94628174c3

@ -99,6 +99,8 @@ message Audience
string OpenId = 1;
string NickName = 2;
string AvatarUrl = 3;
int32 Rank = 4; //
int32 WinningStreak = 5; //
}
//

@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/redis/go-redis/v9"
"os"
)
type RankInfo struct {
@ -16,7 +17,7 @@ type RankInfo struct {
var client *redis.Client
func init() {
url := "redis://:adhd@123@101.35.201.220:6379/1?protocol=3"
url := os.Getenv("REDIS_URL")
opts, err := redis.ParseURL(url)
if err != nil {
panic(err)
@ -71,7 +72,7 @@ func SetAudience(data *pb.Audience) {
client.Set(ctx, key, string(jsonData), -1)
}
func GetAudience(openId string) *pb.Audience {
func GetAudience(appId string, openId string) *pb.Audience {
ctx := context.Background()
key := fmt.Sprintf("UserData_%s", openId)
result, err := client.Get(ctx, key).Result()
@ -83,6 +84,13 @@ func GetAudience(openId string) *pb.Audience {
if err != nil {
return nil
}
scoreKey := fmt.Sprintf("Score_%s", appId)
cmd := client.HGet(ctx, scoreKey, openId)
result, err = cmd.Result()
if err == nil {
}
return data
}

@ -1,10 +1,31 @@
if [ -f "pid.main" ];then
pid=`cat pid.main`
#stop
if [ -f "pid.main" ]; then
pid=$(cat pid.main)
echo "Stop Server main Process Id:$pid"
kill $pid
rm -f pid.main
fi
chmod 777 ./main
"./main" > ./log/main.log 2> ./log/main.error &pid=$!
echo "$pid" > pid.main
version_old=$(git rev-parse origin/master)
git pull
version_new=$(git rev-parse origin/master)
#go build
if [ "$version_old" != "$version_new" ] || [ ! -f "main" ]; then
echo "new version $version_new"
export PATH=$PATH:/usr/local/go/bin
go build -gcflags "all=-N -l" -o main -mod=vendor cmd/main.go
chmod 777 main
fi
#create log dir
if [ ! -d "log" ]; then
mkdir log
fi
#start
export REDIS_URL="redis://:adhd@123@101.35.201.220:6381/2?protocol=3"
"./main" >./log/main.log 2>./log/main.error &
pid=$!
echo "$pid" >pid.main
echo "main Sever Process Id:$pid"
Loading…
Cancel
Save