1
This commit is contained in:
parent
7b824f61b4
commit
0c5049f80d
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,3 +1,9 @@
|
|||||||
[submodule "third_party/phpcommon"]
|
[submodule "third_party/phpcommon"]
|
||||||
path = third_party/phpcommon
|
path = third_party/phpcommon
|
||||||
url = git@git.kingsome.cn:server_common/phpcommon.git
|
url = git@git.kingsome.cn:server_common/phpcommon.git
|
||||||
|
[submodule "third_party/f7"]
|
||||||
|
path = third_party/f7
|
||||||
|
url = git@git.kingsome.cn:server_common/f7.git
|
||||||
|
[submodule "third_party/q7"]
|
||||||
|
path = third_party/q7
|
||||||
|
url = git@git.kingsome.cn:server_common/q7.git
|
||||||
|
1
third_party/f7
vendored
Submodule
1
third_party/f7
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 1d7840b984d20261df241e39db0d8089a831f5b3
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 1e3bb4df855f6d11df75545d10b0c2aacea34a06
|
Subproject commit c1eb6b3006cca677b7e7a06b2e2ac0e9d0108fd4
|
1
third_party/q7
vendored
Submodule
1
third_party/q7
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 4af43d56490d566c38021d9687975dae17d9e7ad
|
0
tools/rankserver/__init__.py
Normal file
0
tools/rankserver/__init__.py
Normal file
BIN
tools/rankserver/__pycache__/app.cpython-36.pyc
Normal file
BIN
tools/rankserver/__pycache__/app.cpython-36.pyc
Normal file
Binary file not shown.
@ -1,27 +1,42 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append('../local_packages')
|
||||||
|
import q7
|
||||||
|
import f7
|
||||||
|
|
||||||
import pymysql
|
import pymysql
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import base64
|
import base64
|
||||||
import tornado.ioloop
|
|
||||||
import tornado.web
|
|
||||||
import time
|
import time
|
||||||
import datetime
|
import datetime
|
||||||
import redis
|
import redis
|
||||||
import os
|
import os
|
||||||
|
import functools
|
||||||
|
|
||||||
CONFIG_DIR = ''
|
|
||||||
|
|
||||||
def IsOnlineEnv():
|
CONFIG_DIR = '../config' if f7.isOnlineEnv() else '/var/data/conf_test/game2001api_rankserver/config'
|
||||||
return os.getenv("SERVER_ENV");
|
|
||||||
|
def _take_pass(elem):
|
||||||
|
return elem[3]
|
||||||
|
|
||||||
|
def _getRedis():
|
||||||
|
redis_conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
|
||||||
|
for conf in redis_conf:
|
||||||
|
r = redis.Redis(host = conf['host'],
|
||||||
|
port = conf['port'],
|
||||||
|
password = conf['passwd'],
|
||||||
|
charset = 'utf8'
|
||||||
|
)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
def getRedisConf():
|
||||||
|
redis_conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
|
||||||
|
return redis_conf;
|
||||||
|
|
||||||
if (IsOnlineEnv()):
|
|
||||||
CONFIG_DIR = '/var/data/conf_test/game2001api_rankserver/config'
|
|
||||||
else:
|
|
||||||
CONFIG_DIR = '../config'
|
|
||||||
|
|
||||||
def info(msg):
|
def info(msg):
|
||||||
print(str(datetime.datetime.now()) + '[INFO] ' + msg)
|
print(str(datetime.datetime.now()) + '[INFO] ' + msg)
|
||||||
@ -41,33 +56,22 @@ def safeDiv(a, b):
|
|||||||
else:
|
else:
|
||||||
return a / b
|
return a / b
|
||||||
|
|
||||||
def getRedis():
|
|
||||||
redis_conf = json.loadsmysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
|
|
||||||
for conf in redis_conf:
|
|
||||||
r = redis.Redis(host = conf['host'],
|
|
||||||
port = conf['port'],
|
|
||||||
password = conf['passwd'],
|
|
||||||
charset = 'utf8'
|
|
||||||
)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
def getDaySeconds(time_val, incdays):
|
def getDaySeconds(time_val, incdays):
|
||||||
time_zone = 8
|
time_zone = 8
|
||||||
dayseconds = int((time_val + time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * time_zone;
|
dayseconds = int((time_val + time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * time_zone;
|
||||||
return dayseconds
|
return dayseconds
|
||||||
|
|
||||||
#数据去重
|
#数据去重
|
||||||
def delRepeatData(row, data_list):
|
def _delRepeatData(row, data_list):
|
||||||
temp_list = []
|
temp_list = []
|
||||||
for data in data_list:
|
for data in data_list:
|
||||||
if data[0] == row[0]:
|
if data[0] == row[0]:
|
||||||
temp_list.append(data)
|
temp_list.append(data)
|
||||||
for temp_data in temp_list:
|
for temp_data in temp_list:
|
||||||
data_list.remove(temp_data)
|
data_list.remove(temp_data)
|
||||||
#print(data_list)
|
|
||||||
|
|
||||||
#刷新数据
|
#刷新数据
|
||||||
def refreshData(row, data_list, data_info):
|
def _refreshData(row, data_list, data_info):
|
||||||
key_info = data_info
|
key_info = data_info
|
||||||
kill = safeDiv(row[3], row[7])
|
kill = safeDiv(row[3], row[7])
|
||||||
alive_time = safeDiv(row[4], row[7])
|
alive_time = safeDiv(row[4], row[7])
|
||||||
@ -82,33 +86,33 @@ def refreshData(row, data_list, data_info):
|
|||||||
del data_list[50:]
|
del data_list[50:]
|
||||||
|
|
||||||
#更新排行榜
|
#更新排行榜
|
||||||
def updateRank(r, kill_list, win_list ,integral_list):
|
def _updateKillRank(r, channel, kill_list):
|
||||||
kill_list.sort(key=take_kills, reverse=True)
|
kill_list.sort(key=take_kills, reverse=True)
|
||||||
kill_rank = []
|
kill_rank = []
|
||||||
for kill_index in range(min(50, len(kill_list))):
|
for kill_index in range(min(50, len(kill_list))):
|
||||||
kill_rank.append(kill_list[kill_index])
|
kill_rank.append(kill_list[kill_index])
|
||||||
r.set("game2001api: kill_rank", json.dumps(kill_rank))
|
r.set("game2001api:kill_rank_" + channel, json.dumps(kill_rank))
|
||||||
|
|
||||||
|
def _updateWinRank(r, channel, win_list):
|
||||||
win_list.sort(key=take_game_times, reverse=True)
|
win_list.sort(key=take_game_times, reverse=True)
|
||||||
win_rank = []
|
win_rank = []
|
||||||
for win_index in range(min(50, len(win_list))):
|
for win_index in range(min(50, len(win_list))):
|
||||||
win_rank.append(win_list[win_index])
|
win_rank.append(win_list[win_index])
|
||||||
r.set("game2001api: win_rank", json.dumps(win_rank))
|
r.set("game2001api:win_rank_" + channel, json.dumps(win_rank))
|
||||||
|
|
||||||
|
def _updateScoreRank(r, channel, integral_list):
|
||||||
integral_list.sort(key=take_integral_times, reverse=True)
|
integral_list.sort(key=take_integral_times, reverse=True)
|
||||||
integral_rank = []
|
integral_rank = []
|
||||||
for integral_index in range(min(50, len(integral_list))):
|
for integral_index in range(min(50, len(integral_list))):
|
||||||
integral_rank.append(integral_list[integral_index])
|
integral_rank.append(integral_list[integral_index])
|
||||||
r.set("game2001api: integral_rank", json.dumps(integral_rank))
|
r.set("game2001api:integral_rank_" + channel, json.dumps(integral_rank))
|
||||||
|
|
||||||
def internalDayReadMysqlData():
|
def fullUpdateRank():
|
||||||
|
f7.udplog.info('fullUpdateRank begin')
|
||||||
mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read())
|
mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read())
|
||||||
kill_list = []
|
kill_hash = {}
|
||||||
alive_list = []
|
win_hash = {}
|
||||||
harm_list = []
|
integral_hash = {}
|
||||||
rate_list = []
|
|
||||||
win_list = []
|
|
||||||
integral_list = []
|
|
||||||
for conf in mysql_conf:
|
for conf in mysql_conf:
|
||||||
conn = pymysql.connect(host = conf['host'],
|
conn = pymysql.connect(host = conf['host'],
|
||||||
port = conf['port'],
|
port = conf['port'],
|
||||||
@ -123,55 +127,53 @@ def internalDayReadMysqlData():
|
|||||||
while 1:
|
while 1:
|
||||||
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
||||||
' harm, win_times, game_times, idx, integral, season_time FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx))
|
' harm, win_times, game_times, idx, integral, season_time FROM user WHERE idx > %s LIMIT 0, 1000' % (last_idx))
|
||||||
|
|
||||||
has_data = False
|
has_data = False
|
||||||
for row in cursor:
|
for row in cursor:
|
||||||
has_data = True
|
has_data = True
|
||||||
#更新击杀榜
|
#更新击杀榜
|
||||||
refreshData(row, kill_list, take_kills)
|
channel = f7.getChannelByAccountId(row[0])
|
||||||
|
if channel not in kill_hash:
|
||||||
|
kill_hash[channel] = []
|
||||||
|
_refreshData(row, kill_hash[channel], take_kills)
|
||||||
#更新胜场榜
|
#更新胜场榜
|
||||||
refreshData(row, win_list, take_game_times)
|
channel = f7.getChannelByAccountId(row[0])
|
||||||
|
if channel not in win_hash:
|
||||||
|
win_hash[channel] = []
|
||||||
|
_refreshData(row, win_hash[channel], take_game_times)
|
||||||
#更新积分榜
|
#更新积分榜
|
||||||
refreshData(row, integral_list, take_integral_times)
|
channel = f7.getChannelByAccountId(row[0])
|
||||||
temp_idx = int(row[8])
|
if channel not in integral_hash:
|
||||||
if (temp_idx > last_idx) :
|
integral_hash[channel] = []
|
||||||
last_idx = int(row[8])
|
_refreshData(row, integral_hash[channel], take_integral_times)
|
||||||
|
last_idx = max(row[8], last_idx)
|
||||||
|
time.sleep(0.001);
|
||||||
if not has_data:
|
if not has_data:
|
||||||
break
|
break
|
||||||
|
|
||||||
r = getRedis()
|
r = _getRedis()
|
||||||
updateRank(r, kill_list, win_list, integral_list)
|
for channel in kill_hash:
|
||||||
|
_updateKillRank(r, channel, kill_hash[channel])
|
||||||
|
for channel in win_hash:
|
||||||
|
_updateWinRank(r, channel, win_hash[channel])
|
||||||
|
for channel in integral_hash:
|
||||||
|
_updateScoreRank(r, channel, integral_hash[channel])
|
||||||
|
f7.udplog.info('fullUpdateRank end')
|
||||||
|
|
||||||
#每日定时读取mysql里的数据生成排行榜写入redis后php读取redis返回客户端显示
|
#每日定时读取mysql里的数据生成排行榜写入redis后php读取redis返回客户端显示
|
||||||
def dayReadMysqlData(rushtime):
|
def _fullUpdateRank(rushtime):
|
||||||
internalDayReadMysqlData()
|
def done_callback():
|
||||||
tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + rushtime,
|
f7.timer.callAt(q7.getDaySeconds(time.time(), 1) + rushtime,
|
||||||
lambda : dayReadMysqlData(rushtime)
|
lambda : _fullUpdateRank(rushtime))
|
||||||
)
|
f7.app.createAsyncTask(done_callback, fullUpdateRank, ())
|
||||||
|
|
||||||
|
|
||||||
#每5分钟读取mysql里发生改变过的数据更新排行榜
|
#每5分钟读取mysql里发生改变过的数据更新排行榜
|
||||||
def readMysqlData(rushtime):
|
def incrementUpdateRank(rushtime):
|
||||||
mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read())
|
mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.mysql.cluster.json', 'r').read())
|
||||||
r = getRedis()
|
r = _getRedis()
|
||||||
kill_list_str = r.get("game2001api: kill_rank")
|
kill_hash = {}
|
||||||
if (not kill_list_str):
|
win_hash = {}
|
||||||
kill_list = []
|
integral_hash = {}
|
||||||
else:
|
|
||||||
kill_list = json.loads(kill_list_str)
|
|
||||||
|
|
||||||
win_list_str = r.get("game2001api: win_rank")
|
|
||||||
if (not win_list_str):
|
|
||||||
win_list = []
|
|
||||||
else:
|
|
||||||
win_list = json.loads(win_list_str)
|
|
||||||
|
|
||||||
integral_list_str = r.get("game2001api: integral_rank")
|
|
||||||
if (not integral_list_str):
|
|
||||||
integral_list = []
|
|
||||||
else:
|
|
||||||
integral_list = json.loads(integral_list_str)
|
|
||||||
|
|
||||||
for conf in mysql_conf:
|
for conf in mysql_conf:
|
||||||
conn = pymysql.connect(host = conf['host'],
|
conn = pymysql.connect(host = conf['host'],
|
||||||
port = conf['port'],
|
port = conf['port'],
|
||||||
@ -190,83 +192,59 @@ def readMysqlData(rushtime):
|
|||||||
has_data = False
|
has_data = False
|
||||||
for row in cursor:
|
for row in cursor:
|
||||||
has_data = True
|
has_data = True
|
||||||
|
channel = f7.getChannelByAccountId(row[0])
|
||||||
#更新击杀榜
|
#更新击杀榜
|
||||||
delRepeatData(row, kill_list)
|
if channel not in kill_hash:
|
||||||
refreshData(row, kill_list, take_kills)
|
kill_list = r.get('game2001api:kill_rank_' + channel)
|
||||||
temp_idx = int(row[8])
|
kill_hash[channel] = [] if not kill_list else json.loads(kill_list)
|
||||||
if (temp_idx > last_idx) :
|
_delRepeatData(row, kill_hash[channel])
|
||||||
last_idx = int(row[8])
|
_refreshData(row, kill_hash[channel], take_kills)
|
||||||
if not has_data:
|
|
||||||
break
|
|
||||||
|
|
||||||
last_idx = 0
|
|
||||||
temp_idx = 0
|
|
||||||
while 1:
|
|
||||||
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
|
||||||
' harm, win_times, game_times, idx, integral, season_time, win_modifytime FROM user '
|
|
||||||
' WHERE win_modifytime > %s AND idx > %s LIMIT 0, 1000' % (time.time() - 300, last_idx))
|
|
||||||
has_data = False
|
|
||||||
for row in cursor:
|
|
||||||
has_data = True
|
|
||||||
#更新胜场榜
|
#更新胜场榜
|
||||||
delRepeatData(row, win_list)
|
if channel not in win_hash:
|
||||||
refreshData(row, win_list, take_game_times)
|
win_list = r.get('game2001api:win_rank_' + channel)
|
||||||
temp_idx = int(row[8])
|
win_hash[channel] = [] if not win_list else json.loads(win_list)
|
||||||
if (temp_idx > last_idx) :
|
_delRepeatData(row, win_hash[channel])
|
||||||
last_idx = int(row[8])
|
_refreshData(row, win_hash[channel], take_game_times)
|
||||||
if not has_data:
|
|
||||||
break
|
|
||||||
|
|
||||||
last_idx = 0
|
|
||||||
temp_idx = 0
|
|
||||||
while 1:
|
|
||||||
cursor.execute('SELECT accountid, user_name, avatar_url, kills, alive_time,'
|
|
||||||
' harm, win_times, game_times, idx, integral, season_time, rank_modifytime FROM user '
|
|
||||||
' WHERE rank_modifytime > %s AND idx > %s LIMIT 0, 1000' % (time.time() - 300, last_idx))
|
|
||||||
|
|
||||||
has_data = False
|
|
||||||
for row in cursor:
|
|
||||||
has_data = True
|
|
||||||
#更新积分榜
|
#更新积分榜
|
||||||
delRepeatData(row, integral_list)
|
if channel not in integral_hash:
|
||||||
refreshData(row, integral_list, take_integral_times)
|
integral_list = r.get('game2001api:integral_rank_' + channel)
|
||||||
temp_idx = int(row[8])
|
integral_hash[channel] = [] if not integral_list else json.loads(integral_list)
|
||||||
if (temp_idx > last_idx) :
|
_delRepeatData(row, integral_hash[channel])
|
||||||
last_idx = int(row[8])
|
_refreshData(row, integral_hash[channel], take_integral_times)
|
||||||
|
last_idx = max(row[8], last_idx)
|
||||||
|
time.sleep(0.001);
|
||||||
if not has_data:
|
if not has_data:
|
||||||
break
|
break
|
||||||
updateRank(r, kill_list, win_list, integral_list)
|
|
||||||
tornado.ioloop.IOLoop.current().call_later(rushtime,
|
|
||||||
lambda : readMysqlData(rushtime)
|
|
||||||
)
|
|
||||||
|
|
||||||
class SelfCheckingHandler(tornado.web.RequestHandler):
|
for channel in kill_hash:
|
||||||
|
_updateKillRank(r, channel, kill_hash[channel])
|
||||||
|
for channel in win_hash:
|
||||||
|
_updateWinRank(r, channel, win_hash[channel])
|
||||||
|
for channel in integral_hash:
|
||||||
|
_updateScoreRank(r, channel, integral_hash[channel])
|
||||||
|
f7.udplog.info('incrementUpdateRank end')
|
||||||
|
|
||||||
def get(self):
|
#每5分钟读取mysql里发生改变过的数据更新排行榜
|
||||||
self.write(json.dumps({
|
def _incrementUpdateRank(rushtime):
|
||||||
'errcode': 0,
|
def done_callback():
|
||||||
'errmsg': '',
|
f7.timer.callLater(rushtime,
|
||||||
'healthy': 1,
|
lambda : _incrementUpdateRank(rushtime))
|
||||||
'max_rundelay': 10
|
f7.app.createAsyncTask(done_callback, incrementUpdateRank, ())
|
||||||
}))
|
|
||||||
|
|
||||||
def make_app():
|
|
||||||
return tornado.web.Application([
|
|
||||||
(r"/webapp/index[\.]php", SelfCheckingHandler),
|
|
||||||
])
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
q7.xPrint('pid %d' % os.getpid())
|
||||||
|
f7.app.init('/data/logs/game2001_rankserver/logs')
|
||||||
|
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())
|
||||||
|
|
||||||
app = make_app()
|
|
||||||
app.listen(conf['listen_port'])
|
|
||||||
conf['rushtime'] = 300
|
conf['rushtime'] = 300
|
||||||
tornado.ioloop.IOLoop.current().call_later(conf['rushtime'],
|
f7.timer.callLater(conf['rushtime'],
|
||||||
lambda : readMysqlData(conf['rushtime'])
|
lambda : _incrementUpdateRank(conf['rushtime']))
|
||||||
)
|
|
||||||
|
|
||||||
conf['day_rushtime'] = 5 * 3600
|
conf['day_rushtime'] = 5 * 3600
|
||||||
tornado.ioloop.IOLoop.current().call_at(getDaySeconds(time.time(), 1) + conf['day_rushtime'],
|
f7.timer.callAt(q7.getDaySeconds(time.time(), 1) + conf['day_rushtime'],
|
||||||
lambda : dayReadMysqlData(conf['day_rushtime'])
|
lambda : _fullUpdateRank(conf['day_rushtime']))
|
||||||
)
|
|
||||||
tornado.ioloop.IOLoop.current().start()
|
f7.app.listen(conf['listen_port'])
|
||||||
|
f7.app.start()
|
||||||
|
70
tools/rankserver/rankserver_cmd.py
Normal file
70
tools/rankserver/rankserver_cmd.py
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append('../local_packages')
|
||||||
|
import q7
|
||||||
|
import f7
|
||||||
|
|
||||||
|
import pymysql
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
import redis
|
||||||
|
import os
|
||||||
|
|
||||||
|
import app
|
||||||
|
|
||||||
|
def _updateRank_cmd(debug_info):
|
||||||
|
app.fullUpdateRank()
|
||||||
|
|
||||||
|
def _clearRank_cmd(debug_info):
|
||||||
|
for conf in app.getRedisConf():
|
||||||
|
r = redis.Redis(host = conf['host'],
|
||||||
|
port = conf['port'],
|
||||||
|
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_*")
|
||||||
|
for key in kill_keys :
|
||||||
|
r.delete(key)
|
||||||
|
for key in win_keys :
|
||||||
|
r.delete(key)
|
||||||
|
for key in integral_keys :
|
||||||
|
r.delete(key)
|
||||||
|
|
||||||
|
def processCmdLine(cmd):
|
||||||
|
cmd_hash = {
|
||||||
|
'updateRank': _updateRank_cmd,
|
||||||
|
'clearRank': _clearRank_cmd,
|
||||||
|
}
|
||||||
|
precmd_hash = {
|
||||||
|
}
|
||||||
|
postcmd_hash = {
|
||||||
|
}
|
||||||
|
debug_info = {
|
||||||
|
'record_count': 0,
|
||||||
|
'param1': 0,
|
||||||
|
'param2': 0,
|
||||||
|
'param3': 0,
|
||||||
|
'param4': 0
|
||||||
|
}
|
||||||
|
if cmd in precmd_hash:
|
||||||
|
precmd_hash[cmd](debug_info)
|
||||||
|
if cmd in cmd_hash:
|
||||||
|
cmd_hash[cmd](debug_info)
|
||||||
|
if cmd in postcmd_hash:
|
||||||
|
postcmd_hash[cmd](debug_info)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) <= 1:
|
||||||
|
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()))
|
||||||
|
processCmdLine(sys.argv[1])
|
||||||
|
f7.app.start()
|
@ -97,7 +97,7 @@ class RankController{
|
|||||||
$myname = $row['user_name'];
|
$myname = $row['user_name'];
|
||||||
$myavatar_url = $row['avatar_url'];
|
$myavatar_url = $row['avatar_url'];
|
||||||
}
|
}
|
||||||
|
$myavatar_url = urldecode($myavatar_url);
|
||||||
array_push($user_list, array(
|
array_push($user_list, array(
|
||||||
'account_id' => $account_id,
|
'account_id' => $account_id,
|
||||||
'name' => $myname,
|
'name' => $myname,
|
||||||
@ -114,7 +114,8 @@ class RankController{
|
|||||||
ini_set('memory_limit','3072M');
|
ini_set('memory_limit','3072M');
|
||||||
//击杀榜
|
//击杀榜
|
||||||
$r = $this->getRedis();
|
$r = $this->getRedis();
|
||||||
$kill_rank_db = $r->get("game2001api: kill_rank");
|
$channel = phpcommon\extractChannel($account_id);
|
||||||
|
$kill_rank_db = $r->get("game2001api:kill_rank_" . $channel);
|
||||||
$kill_db = json_decode($kill_rank_db);
|
$kill_db = json_decode($kill_rank_db);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($kill_db as $kill) {
|
foreach ($kill_db as $kill) {
|
||||||
@ -147,10 +148,11 @@ class RankController{
|
|||||||
$name = $kill_db[$i][1];
|
$name = $kill_db[$i][1];
|
||||||
$avatar_url = $kill_db[$i][2];
|
$avatar_url = $kill_db[$i][2];
|
||||||
}
|
}
|
||||||
|
$url = urldecode($avatar_url);
|
||||||
array_push($kill_list, array(
|
array_push($kill_list, array(
|
||||||
'account_id' => $kill_db[$i][0],
|
'account_id' => $kill_db[$i][0],
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'avatar_url' => $avatar_url,
|
'avatar_url' => $url,
|
||||||
'kill' => $kill_db[$i][3],
|
'kill' => $kill_db[$i][3],
|
||||||
'alive'=> $kill_db[$i][4],
|
'alive'=> $kill_db[$i][4],
|
||||||
'harm' => $kill_db[$i][5],
|
'harm' => $kill_db[$i][5],
|
||||||
@ -162,7 +164,8 @@ class RankController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//胜场榜
|
//胜场榜
|
||||||
$win_rank_db = $r->get("game2001api: win_rank");
|
$channel = phpcommon\extractChannel($account_id);
|
||||||
|
$win_rank_db = $r->get("game2001api:win_rank_" . $channel);
|
||||||
$win_db = json_decode($win_rank_db);
|
$win_db = json_decode($win_rank_db);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($win_db as $win) {
|
foreach ($win_db as $win) {
|
||||||
@ -195,10 +198,11 @@ class RankController{
|
|||||||
$name = $win_db[$i][1];
|
$name = $win_db[$i][1];
|
||||||
$avatar_url = $win_db[$i][2];
|
$avatar_url = $win_db[$i][2];
|
||||||
}
|
}
|
||||||
|
$url = urldecode($avatar_url);
|
||||||
array_push($win_list, array(
|
array_push($win_list, array(
|
||||||
'account_id' => $win_db[$i][0],
|
'account_id' => $win_db[$i][0],
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'avatar_url' => $avatar_url,
|
'avatar_url' => $url,
|
||||||
'kill' => $win_db[$i][3],
|
'kill' => $win_db[$i][3],
|
||||||
'alive'=> $win_db[$i][4],
|
'alive'=> $win_db[$i][4],
|
||||||
'harm' => $win_db[$i][5],
|
'harm' => $win_db[$i][5],
|
||||||
@ -209,7 +213,8 @@ class RankController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//积分榜
|
//积分榜
|
||||||
$integral_rank_db = $r->get("game2001api: integral_rank");
|
$channel = phpcommon\extractChannel($account_id);
|
||||||
|
$integral_rank_db = $r->get("game2001api:integral_rank_" . $channel);
|
||||||
$integral_db = json_decode($integral_rank_db);
|
$integral_db = json_decode($integral_rank_db);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($integral_db as $integral) {
|
foreach ($integral_db as $integral) {
|
||||||
@ -254,10 +259,11 @@ class RankController{
|
|||||||
$name = $integral_db[$i][1];
|
$name = $integral_db[$i][1];
|
||||||
$avatar_url = $integral_db[$i][2];
|
$avatar_url = $integral_db[$i][2];
|
||||||
}
|
}
|
||||||
|
$url = urldecode($avatar_url);
|
||||||
array_push($integral_list, array(
|
array_push($integral_list, array(
|
||||||
'account_id' => $integral_db[$i][0],
|
'account_id' => $integral_db[$i][0],
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'avatar_url' => $avatar_url,
|
'avatar_url' => $url,
|
||||||
'kill' => $integral_db[$i][3],
|
'kill' => $integral_db[$i][3],
|
||||||
'alive'=> $integral_db[$i][4],
|
'alive'=> $integral_db[$i][4],
|
||||||
'harm' => $integral_db[$i][5],
|
'harm' => $integral_db[$i][5],
|
||||||
|
@ -373,13 +373,6 @@ class ShopController{
|
|||||||
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
phpcommon\sendError(ERR_USER_BASE + 1,'session失效');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($_REQUEST['type'] == 3) {
|
|
||||||
$p = $this->getParameter(RAND_SHOP_GOLD);
|
|
||||||
if ($shop_type == 2) {
|
|
||||||
$p = $this->getParameter(RAND_DIAMONDSHOP_GOLD);
|
|
||||||
}
|
|
||||||
$this->SubCoin($p['param_value'], $account_id, $_REQUEST['type']);
|
|
||||||
}
|
|
||||||
unset($user_db['shop_list']);
|
unset($user_db['shop_list']);
|
||||||
$shop_list = $this->randomShop($shop_type);
|
$shop_list = $this->randomShop($shop_type);
|
||||||
$user_db['shop_list'] = $shop_list;
|
$user_db['shop_list'] = $shop_list;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user