1
This commit is contained in:
parent
d979806349
commit
c240c939fd
@ -18,7 +18,7 @@ import os
|
||||
import functools
|
||||
|
||||
|
||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2001api_rankserver/config'
|
||||
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2004api_rankserver/config'
|
||||
|
||||
def _take_pass(elem):
|
||||
return elem[3]
|
||||
@ -91,21 +91,21 @@ def _updateKillRank(r, channel, kill_list):
|
||||
kill_rank = []
|
||||
for kill_index in range(min(50, len(kill_list))):
|
||||
kill_rank.append(kill_list[kill_index])
|
||||
r.set("game2001api:kill_rank_" + channel, json.dumps(kill_rank))
|
||||
r.set("game2004api:kill_rank_" + channel, json.dumps(kill_rank))
|
||||
|
||||
def _updateWinRank(r, channel, win_list):
|
||||
win_list.sort(key=take_game_times, reverse=True)
|
||||
win_rank = []
|
||||
for win_index in range(min(50, len(win_list))):
|
||||
win_rank.append(win_list[win_index])
|
||||
r.set("game2001api:win_rank_" + channel, json.dumps(win_rank))
|
||||
r.set("game2004api:win_rank_" + channel, json.dumps(win_rank))
|
||||
|
||||
def _updateScoreRank(r, channel, integral_list):
|
||||
integral_list.sort(key=take_integral_times, reverse=True)
|
||||
integral_rank = []
|
||||
for integral_index in range(min(50, len(integral_list))):
|
||||
integral_rank.append(integral_list[integral_index])
|
||||
r.set("game2001api:integral_rank_" + channel, json.dumps(integral_rank))
|
||||
r.set("game2004api:integral_rank_" + channel, json.dumps(integral_rank))
|
||||
|
||||
def fullUpdateRank():
|
||||
f7.udplog.info('fullUpdateRank begin')
|
||||
@ -118,7 +118,7 @@ def fullUpdateRank():
|
||||
port = conf['port'],
|
||||
user = conf['user'],
|
||||
passwd = conf['passwd'],
|
||||
db = 'gamedb2001_' + str(conf['instance_id']),
|
||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
||||
charset = 'utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
@ -179,7 +179,7 @@ def incrementUpdateRank(rushtime):
|
||||
port = conf['port'],
|
||||
user = conf['user'],
|
||||
passwd = conf['passwd'],
|
||||
db = 'gamedb2001_' + str(conf['instance_id']),
|
||||
db = 'gamedb2004_' + str(conf['instance_id']),
|
||||
charset = 'utf8'
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
@ -195,19 +195,19 @@ def incrementUpdateRank(rushtime):
|
||||
channel = f7.getChannelByAccountId(row[0])
|
||||
#更新击杀榜
|
||||
if channel not in kill_hash:
|
||||
kill_list = r.get('game2001api:kill_rank_' + channel)
|
||||
kill_list = r.get('game2004api: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('game2001api:win_rank_' + channel)
|
||||
win_list = r.get('game2004api: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('game2001api:integral_rank_' + channel)
|
||||
integral_list = r.get('game2004api: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)
|
||||
@ -233,7 +233,7 @@ def _incrementUpdateRank(rushtime):
|
||||
|
||||
if __name__ == "__main__":
|
||||
q7.xPrint('pid %d' % os.getpid())
|
||||
f7.app.init('/data/logs/game2001_rankserver/logs')
|
||||
f7.app.init('/data/logs/game2004_rankserver/logs')
|
||||
f7.udplog.info('rankserver start pid:' + str(os.getpid()))
|
||||
|
||||
conf = json.loads(open(CONFIG_DIR + '/rankserver.json', 'r').read())
|
||||
|
@ -26,9 +26,9 @@ def _clearRank_cmd(debug_info):
|
||||
password = conf['passwd'],
|
||||
charset = 'utf8'
|
||||
)
|
||||
kill_keys = f7.scanRedisKey(r, "game2001api:kill_rank_*")
|
||||
win_keys = f7.scanRedisKey(r, "game2001api:win_rank_*")
|
||||
integral_keys = f7.scanRedisKey(r, "game2001api:integral_rank_*")
|
||||
kill_keys = f7.scanRedisKey(r, "game2004api:kill_rank_*")
|
||||
win_keys = f7.scanRedisKey(r, "game2004api:win_rank_*")
|
||||
integral_keys = f7.scanRedisKey(r, "game2004api:integral_rank_*")
|
||||
for key in kill_keys :
|
||||
r.delete(key)
|
||||
for key in win_keys :
|
||||
@ -64,7 +64,7 @@ if __name__ == "__main__":
|
||||
pass
|
||||
else:
|
||||
q7.xPrint('pid:' + str(os.getpid()))
|
||||
f7.app.init('/data/logs/game2001_rankserver_cmd/logs')
|
||||
f7.udplog.info('game2001_rankserver_cmd start pid:' + str(os.getpid()))
|
||||
f7.app.init('/data/logs/game2004_rankserver_cmd/logs')
|
||||
f7.udplog.info('game2004_rankserver_cmd start pid:' + str(os.getpid()))
|
||||
processCmdLine(sys.argv[1])
|
||||
f7.app.start()
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$g_conf_mysql_cluster = require('../config/game2001api.mysql.cluster.php');
|
||||
$g_conf_redis_cluster = require('../config/game2001api.redis.cluster.php');
|
||||
$g_conf_mysql_cluster = require('../config/game2004api.mysql.cluster.php');
|
||||
$g_conf_redis_cluster = require('../config/game2004api.redis.cluster.php');
|
||||
|
||||
|
||||
function checkMysqlConfig()
|
||||
@ -10,7 +10,7 @@ function checkMysqlConfig()
|
||||
global $g_conf_mysql_cluster;
|
||||
foreach ($g_conf_mysql_cluster as $instance) {
|
||||
if ($instance_id != $instance['instance_id']) {
|
||||
error_log('game2001api.mysql.cluster.php config error');
|
||||
error_log('game2004api.mysql.cluster.php config error');
|
||||
die();
|
||||
}
|
||||
$instance_id++;
|
||||
@ -24,7 +24,7 @@ function checkRedisConfig()
|
||||
global $g_conf_redis_cluster;
|
||||
foreach ($g_conf_redis_cluster as $instance) {
|
||||
if ($instance_id != $instance['instance_id']) {
|
||||
error_log('game2001api.redis.cluster.php config error');
|
||||
error_log('game2004api.redis.cluster.php config error');
|
||||
die();
|
||||
}
|
||||
$instance_id++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user