This commit is contained in:
wangwei01 2019-06-13 20:26:49 +08:00
parent 8a12c9f305
commit 34e11744f4

View File

@ -18,9 +18,9 @@ def IsOnlineEnv():
return os.getenv("SERVER_ENV"); return os.getenv("SERVER_ENV");
if (IsOnlineEnv()): if (IsOnlineEnv()):
CONFIG_DIR = '/var/data/conf_test/game2001api_rankserver/config/rankserver.redis.cluster.json' CONFIG_DIR = '/var/data/conf_test/game2001api_rankserver/config'
else: else:
CONFIG_DIR = '../config/rankserver.redis.cluster.json' CONFIG_DIR = '../config'
#定时读取mysql里的数据生成排行榜写入redis后php读取redis返回客户端显示 #定时读取mysql里的数据生成排行榜写入redis后php读取redis返回客户端显示
@ -49,7 +49,7 @@ def safeDiv(a, b):
return a / b return a / b
def getRedis(): def getRedis():
redis_conf = json.loadsmysql_conf = json.loads(open(CONFIG_DIR, 'r').read()) redis_conf = json.loadsmysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
for conf in redis_conf: for conf in redis_conf:
r = redis.Redis(host = conf['host'], r = redis.Redis(host = conf['host'],
port = conf['port'], port = conf['port'],
@ -60,7 +60,7 @@ def getRedis():
def readMysqlData(rushtime): def readMysqlData(rushtime):
mysql_conf = json.loads(open(CONFIG_DIR, 'r').read()) mysql_conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
array = [] array = []
for conf in mysql_conf: for conf in mysql_conf:
conn = pymysql.connect(host = conf['host'], conn = pymysql.connect(host = conf['host'],
@ -122,7 +122,7 @@ def make_app():
]) ])
if __name__ == "__main__": if __name__ == "__main__":
conf = json.loads(open(CONFIG_DIR, 'r').read()) conf = json.loads(open(CONFIG_DIR + '/rankserver.redis.cluster.json', 'r').read())
app = make_app() app = make_app()
app.listen(conf['listen_port']) app.listen(conf['listen_port'])