未验证 提交 6f8c255a 编写于 作者: 走神的阿圆's avatar 走神的阿圆 提交者: GitHub

Add ProtoUpdater (#631)

上级 e64a3bca
...@@ -154,7 +154,7 @@ def gen_result(status, msg, data): ...@@ -154,7 +154,7 @@ def gen_result(status, msg, data):
return result return result
def create_app(args, method): def create_app(args):
app = Flask(__name__, static_url_path="") app = Flask(__name__, static_url_path="")
# set static expires in a short time to reduce browser's memory usage. # set static expires in a short time to reduce browser's memory usage.
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30 app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 30
...@@ -166,7 +166,7 @@ def create_app(args, method): ...@@ -166,7 +166,7 @@ def create_app(args, method):
# use a memory cache to reduce disk reading frequency. # use a memory cache to reduce disk reading frequency.
CACHE = MemCache(timeout=args.cache_timeout) CACHE = MemCache(timeout=args.cache_timeout)
cache_get = lib.cache_get(CACHE) cache_get = lib.cache_get(CACHE)
update_util.PbUpdater(method).start() update_util.PbUpdater().start()
public_path = args.public_path.rstrip('/') public_path = args.public_path.rstrip('/')
api_path = public_path + '/api' api_path = public_path + '/api'
...@@ -350,7 +350,7 @@ def _run(logdir, ...@@ -350,7 +350,7 @@ def _run(logdir,
language=language, language=language,
public_path=public_path) public_path=public_path)
logger.info(" port=" + str(args.port)) logger.info(" port=" + str(args.port))
app = create_app(args, 'run') app = create_app(args)
index_url = "http://" + host + ":" + str(port) + args.public_path index_url = "http://" + host + ":" + str(port) + args.public_path
if open_browser: if open_browser:
threading.Thread( threading.Thread(
...@@ -401,7 +401,7 @@ def main(): ...@@ -401,7 +401,7 @@ def main():
for sig in [signal.SIGINT, signal.SIGHUP, signal.SIGTERM]: for sig in [signal.SIGINT, signal.SIGHUP, signal.SIGTERM]:
signal.signal(sig, clean_template) signal.signal(sig, clean_template)
logger.info(" port=" + str(args.port)) logger.info(" port=" + str(args.port))
app = create_app(args, 'main') app = create_app(args)
app.run(debug=False, host=args.host, port=args.port, threaded=False) app.run(debug=False, host=args.host, port=args.port, threaded=False)
......
...@@ -29,18 +29,15 @@ def md5(text): ...@@ -29,18 +29,15 @@ def md5(text):
class PbUpdater(threading.Thread): class PbUpdater(threading.Thread):
def __init__(self, start_method): def __init__(self):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.start_method = start_method
def update_pb(self, def update_pb(self,
start_method,
version=__version__, version=__version__,
md5_code=md5(str(DESCRIPTOR)) md5_code=md5(str(DESCRIPTOR))
): ):
payload = { payload = {
"data": { "data": {
"start_method": start_method,
"version": version, "version": version,
"md5": md5_code "md5": md5_code
} }
...@@ -57,7 +54,6 @@ class PbUpdater(threading.Thread): ...@@ -57,7 +54,6 @@ class PbUpdater(threading.Thread):
pass pass
def run(self): def run(self):
self.update_pb(start_method=self.start_method, self.update_pb(version=__version__,
version=__version__,
md5_code=md5(str(DESCRIPTOR)) md5_code=md5(str(DESCRIPTOR))
) )
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册