提交 cc68c13a 编写于 作者: D Dong Daxiang 提交者: GitHub

Merge pull request #401 from guru4elephant/fix_multiple_downloads

make single server to download server bin, and other processes should…
......@@ -211,6 +211,7 @@ class Server(object):
tar_name = floder_name + ".tar.gz"
bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name
self.server_path = os.path.join(self.module_path, floder_name)
if not os.path.exists(self.server_path):
print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate')
......
......@@ -20,6 +20,7 @@ import google.protobuf.text_format
import tarfile
import socket
import paddle_serving_server_gpu as paddle_serving_server
import time
from .version import serving_server_version
from contextlib import closing
import argparse
......@@ -223,11 +224,21 @@ class Server(object):
os.chdir(self.module_path)
need_download = False
device_version = "serving-gpu-"
floder_name = device_version + serving_server_version
tar_name = floder_name + ".tar.gz"
folder_name = device_version + serving_server_version
tar_name = folder_name + ".tar.gz"
bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name
self.server_path = os.path.join(self.module_path, floder_name)
self.server_path = os.path.join(self.module_path, folder_name)
download_flag = "{}/{}.is_download".format(self.module_path,
folder_name)
if os.path.exists(download_flag):
os.chdir(self.cur_path)
self.bin_path = self.server_path + "/serving"
return
if not os.path.exists(self.server_path):
os.system("touch {}/{}.is_download".format(self.module_path,
folder_name))
print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate')
if r != 0:
......@@ -326,4 +337,8 @@ class Server(object):
self.gpuid,)
print("Going to Run Comand")
print(command)
# wait for other process to download server bin
while not os.path.exists(self.server_path):
time.sleep(1)
os.system(command)
......@@ -66,6 +66,12 @@ class WebService(object):
return server
def _launch_rpc_service(self, service_idx):
if service_idx == 0:
self.rpc_service_list[service_idx].check_local_bin()
if not self.rpc_service_list[service_idx].use_local_bin:
self.rpc_service_list[service_idx].download_bin()
else:
time.sleep(3)
self.rpc_service_list[service_idx].run_server()
def prepare_server(self, workdir="", port=9393, device="gpu", gpuid=0):
......@@ -160,15 +166,6 @@ class WebService(object):
if not isinstance(result, dict) and result == -1:
result = {"result": "Request Value Error"}
return result
'''
feed, fetch = self.preprocess(request.json, request.json["fetch"])
if "fetch" in feed:
del feed["fetch"]
fetch_map = client.predict(feed=feed, fetch=fetch)
fetch_map = self.postprocess(
feed=request.json, fetch=fetch, fetch_map=fetch_map)
return fetch_map
'''
app_instance.run(host="0.0.0.0",
port=self.port,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册