From cecfda90fbc31e09d9cd08b7d523e087df49e8b0 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 2 Dec 2020 15:04:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=A6=9C=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E6=94=B9=E4=B8=BA=E5=8F=AF=E4=BB=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/rankserver/app.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/rankserver/app.py b/tools/rankserver/app.py index 87a5131..e7bafb7 100644 --- a/tools/rankserver/app.py +++ b/tools/rankserver/app.py @@ -19,6 +19,8 @@ import functools CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config' +RANK_KEY_PREFIX = 'game2004api:' +DBNAME_PREFIX = 'gamedb2004_' def _take_pass(elem): return elem[3] @@ -123,7 +125,7 @@ def fullUpdateRank(): port = conf['port'], user = conf['user'], passwd = conf['passwd'], - db = 'gamedb2004_' + str(conf['instance_id']), + db = DBNAME_PREFIX + str(conf['instance_id']), charset = 'utf8' ) cursor = conn.cursor() @@ -187,7 +189,7 @@ def incrementUpdateRank(): port = conf['port'], user = conf['user'], passwd = conf['passwd'], - db = 'gamedb2004_' + str(conf['instance_id']), + db = DBNAME_PREFIX + str(conf['instance_id']), charset = 'utf8' ) cursor = conn.cursor() @@ -204,19 +206,19 @@ def incrementUpdateRank(): if checkchannel(channel): #更新击杀榜 if channel not in kill_hash: - kill_list = r.get('game2004api:kill_rank_' + channel) + kill_list = r.get(RANK_KEY_PREFIX + 'kill_rank_' + channel) kill_hash[channel] = [] if not kill_list else json.loads(kill_list) _delRepeatData(row, kill_hash[channel]) _refreshData(row, kill_hash[channel], take_kills) #更新胜场榜 if channel not in win_hash: - win_list = r.get('game2004api:win_rank_' + channel) + win_list = r.get(RANK_KEY_PREFIX + 'win_rank_' + channel) win_hash[channel] = [] if not win_list else json.loads(win_list) _delRepeatData(row, win_hash[channel]) _refreshData(row, win_hash[channel], take_game_times) #更新积分榜 if channel not in integral_hash: - integral_list = r.get('game2004api:integral_rank_' + channel) + integral_list = r.get(RANK_KEY_PREFIX + 'integral_rank_' + channel) integral_hash[channel] = [] if not integral_list else json.loads(integral_list) _delRepeatData(row, integral_hash[channel]) _refreshData(row, integral_hash[channel], take_integral_times) @@ -246,6 +248,8 @@ if __name__ == "__main__": f7.udplog.info('rankserver start pid:' + str(os.getpid())) conf = json.loads(open(CONFIG_DIR + '/rankserver.json', 'r').read()) + RANK_KEY_PREFIX = conf.get('key_prefix', RANK_KEY_PREFIX) + DBNAME_PREFIX = conf.get('dbname_prefix', DBNAME_PREFIX) conf['rushtime'] = 300 f7.timer.callLater(conf['rushtime'],