1
This commit is contained in:
parent
f4e0335746
commit
4a85c10407
@ -11,6 +11,16 @@ import tornado.web
|
||||
import time
|
||||
import datetime
|
||||
import redis
|
||||
import os
|
||||
CONFIG_DIR = ''
|
||||
|
||||
def IsOnlineEnv():
|
||||
return os.getenv("SERVER_ENV");
|
||||
|
||||
if (IsOnlineEnv()):
|
||||
CONFIG_DIR = '/var/data/conf_test/game2001api_rankserver/config/rankserver.redis.cluster.json'
|
||||
else:
|
||||
CONFIG_DIR = '../config'
|
||||
|
||||
#定时读取mysql里的数据生成排行榜写入redis后php读取redis返回客户端显示
|
||||
|
||||
@ -39,7 +49,7 @@ def safeDiv(a, b):
|
||||
return a / b
|
||||
|
||||
def getRedis():
|
||||
redis_conf = json.loadsmysql_conf = json.loads(open('/var/data/conf_test/game2001api_rankserver/config/rankserver.redis.cluster.json', 'r').read())
|
||||
redis_conf = json.loadsmysql_conf = json.loads(open(CONFIG_DIR, 'r').read())
|
||||
for conf in redis_conf:
|
||||
r = redis.Redis(host = conf['host'],
|
||||
port = conf['port'],
|
||||
@ -50,7 +60,7 @@ def getRedis():
|
||||
|
||||
|
||||
def readMysqlData(rushtime):
|
||||
mysql_conf = json.loads(open('/var/data/conf_test/game2001api_rankserver/config/rankserver.mysql.cluster.json', 'r').read())
|
||||
mysql_conf = json.loads(open(CONFIG_DIR, 'r').read())
|
||||
array = []
|
||||
for conf in mysql_conf:
|
||||
conn = pymysql.connect(host = conf['host'],
|
||||
@ -112,7 +122,7 @@ def make_app():
|
||||
])
|
||||
|
||||
if __name__ == "__main__":
|
||||
conf = json.loads(open('/var/data/conf_test/game2001api_rankserver/config/rankserver.json', 'r').read())
|
||||
conf = json.loads(open(CONFIG_DIR, 'r').read())
|
||||
|
||||
app = make_app()
|
||||
app.listen(conf['listen_port'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user