排行榜服务器改为可以配置
This commit is contained in:
parent
01a6a452db
commit
cecfda90fb
@ -19,6 +19,8 @@ import functools
|
|||||||
|
|
||||||
|
|
||||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config'
|
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):
|
def _take_pass(elem):
|
||||||
return elem[3]
|
return elem[3]
|
||||||
@ -123,7 +125,7 @@ def fullUpdateRank():
|
|||||||
port = conf['port'],
|
port = conf['port'],
|
||||||
user = conf['user'],
|
user = conf['user'],
|
||||||
passwd = conf['passwd'],
|
passwd = conf['passwd'],
|
||||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
db = DBNAME_PREFIX + str(conf['instance_id']),
|
||||||
charset = 'utf8'
|
charset = 'utf8'
|
||||||
)
|
)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -187,7 +189,7 @@ def incrementUpdateRank():
|
|||||||
port = conf['port'],
|
port = conf['port'],
|
||||||
user = conf['user'],
|
user = conf['user'],
|
||||||
passwd = conf['passwd'],
|
passwd = conf['passwd'],
|
||||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
db = DBNAME_PREFIX + str(conf['instance_id']),
|
||||||
charset = 'utf8'
|
charset = 'utf8'
|
||||||
)
|
)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@ -204,19 +206,19 @@ def incrementUpdateRank():
|
|||||||
if checkchannel(channel):
|
if checkchannel(channel):
|
||||||
#更新击杀榜
|
#更新击杀榜
|
||||||
if channel not in kill_hash:
|
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)
|
kill_hash[channel] = [] if not kill_list else json.loads(kill_list)
|
||||||
_delRepeatData(row, kill_hash[channel])
|
_delRepeatData(row, kill_hash[channel])
|
||||||
_refreshData(row, kill_hash[channel], take_kills)
|
_refreshData(row, kill_hash[channel], take_kills)
|
||||||
#更新胜场榜
|
#更新胜场榜
|
||||||
if channel not in win_hash:
|
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)
|
win_hash[channel] = [] if not win_list else json.loads(win_list)
|
||||||
_delRepeatData(row, win_hash[channel])
|
_delRepeatData(row, win_hash[channel])
|
||||||
_refreshData(row, win_hash[channel], take_game_times)
|
_refreshData(row, win_hash[channel], take_game_times)
|
||||||
#更新积分榜
|
#更新积分榜
|
||||||
if channel not in integral_hash:
|
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)
|
integral_hash[channel] = [] if not integral_list else json.loads(integral_list)
|
||||||
_delRepeatData(row, integral_hash[channel])
|
_delRepeatData(row, integral_hash[channel])
|
||||||
_refreshData(row, integral_hash[channel], take_integral_times)
|
_refreshData(row, integral_hash[channel], take_integral_times)
|
||||||
@ -246,6 +248,8 @@ if __name__ == "__main__":
|
|||||||
f7.udplog.info('rankserver start pid:' + str(os.getpid()))
|
f7.udplog.info('rankserver start pid:' + str(os.getpid()))
|
||||||
|
|
||||||
conf = json.loads(open(CONFIG_DIR + '/rankserver.json', 'r').read())
|
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
|
conf['rushtime'] = 300
|
||||||
f7.timer.callLater(conf['rushtime'],
|
f7.timer.callLater(conf['rushtime'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user