提交 e31e3884 编写于 作者: D dongdaxiang 提交者: MRXLT

make single server to download server bin, and other processes should wait...

make single server to download server bin, and other processes should wait until server bin is available
上级 733577c0
...@@ -211,6 +211,7 @@ class Server(object): ...@@ -211,6 +211,7 @@ class Server(object):
tar_name = floder_name + ".tar.gz" tar_name = floder_name + ".tar.gz"
bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name 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, floder_name)
if not os.path.exists(self.server_path): if not os.path.exists(self.server_path):
print('Frist time run, downloading PaddleServing components ...') print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate') r = os.system('wget ' + bin_url + ' --no-check-certificate')
......
...@@ -20,6 +20,7 @@ import google.protobuf.text_format ...@@ -20,6 +20,7 @@ import google.protobuf.text_format
import tarfile import tarfile
import socket import socket
import paddle_serving_server_gpu as paddle_serving_server import paddle_serving_server_gpu as paddle_serving_server
import time
from .version import serving_server_version from .version import serving_server_version
from contextlib import closing from contextlib import closing
import argparse import argparse
...@@ -215,11 +216,21 @@ class Server(object): ...@@ -215,11 +216,21 @@ class Server(object):
os.chdir(self.module_path) os.chdir(self.module_path)
need_download = False need_download = False
device_version = "serving-gpu-" device_version = "serving-gpu-"
floder_name = device_version + serving_server_version folder_name = device_version + serving_server_version
tar_name = floder_name + ".tar.gz" tar_name = folder_name + ".tar.gz"
bin_url = "https://paddle-serving.bj.bcebos.com/bin/" + tar_name 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): 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 ...') print('Frist time run, downloading PaddleServing components ...')
r = os.system('wget ' + bin_url + ' --no-check-certificate') r = os.system('wget ' + bin_url + ' --no-check-certificate')
if r != 0: if r != 0:
...@@ -318,4 +329,8 @@ class Server(object): ...@@ -318,4 +329,8 @@ class Server(object):
self.gpuid,) self.gpuid,)
print("Going to Run Comand") print("Going to Run Comand")
print(command) print(command)
# wait for other process to download server bin
while not os.path.exists(self.server_path):
time.sleep(1)
os.system(command) os.system(command)
...@@ -66,6 +66,12 @@ class WebService(object): ...@@ -66,6 +66,12 @@ class WebService(object):
return server return server
def _launch_rpc_service(self, service_idx): 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() self.rpc_service_list[service_idx].run_server()
def prepare_server(self, workdir="", port=9393, device="gpu", gpuid=0): def prepare_server(self, workdir="", port=9393, device="gpu", gpuid=0):
...@@ -160,15 +166,6 @@ class WebService(object): ...@@ -160,15 +166,6 @@ class WebService(object):
if not isinstance(result, dict) and result == -1: if not isinstance(result, dict) and result == -1:
result = {"result": "Request Value Error"} result = {"result": "Request Value Error"}
return result 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", app_instance.run(host="0.0.0.0",
port=self.port, port=self.port,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册