提交 9ede6128 编写于 作者: M MRXLT

add inner port

上级 ba86b42a
...@@ -58,6 +58,11 @@ def parse_args(): # pylint: disable=doc-string-missing ...@@ -58,6 +58,11 @@ def parse_args(): # pylint: disable=doc-string-missing
default=False, default=False,
action="store_true", action="store_true",
help="Use Multi-language-service") help="Use Multi-language-service")
parser.add_argument(
"--inner_port",
default=12000,
type=int,
help="Starting port for rpc service")
return parser.parse_args() return parser.parse_args()
...@@ -116,7 +121,10 @@ if __name__ == "__main__": ...@@ -116,7 +121,10 @@ if __name__ == "__main__":
service = WebService(name=args.name) service = WebService(name=args.name)
service.load_model_config(args.model) service.load_model_config(args.model)
service.prepare_server( service.prepare_server(
workdir=args.workdir, port=args.port, device=args.device) workdir=args.workdir,
port=args.port,
inner_port=args.inner_port,
device=args.device)
service.run_rpc_service() service.run_rpc_service()
app_instance = Flask(__name__) app_instance = Flask(__name__)
......
...@@ -60,13 +60,14 @@ class WebService(object): ...@@ -60,13 +60,14 @@ class WebService(object):
def prepare_server(self, def prepare_server(self,
workdir="", workdir="",
port=9393, port=9393,
inner_port=12000,
device="cpu", device="cpu",
mem_optim=True, mem_optim=True,
ir_optim=False): ir_optim=False):
self.workdir = workdir self.workdir = workdir
self.port = port self.port = port
self.device = device self.device = device
default_port = 12000 default_port = inner_port
self.port_list = [] self.port_list = []
self.mem_optim = mem_optim self.mem_optim = mem_optim
self.ir_optim = ir_optim self.ir_optim = ir_optim
......
...@@ -73,6 +73,11 @@ def serve_args(): ...@@ -73,6 +73,11 @@ def serve_args():
default=False, default=False,
action="store_true", action="store_true",
help="Use Multi-language-service") help="Use Multi-language-service")
parser.add_argument(
"--inner_port",
type=int,
default=12000,
help="Starting port of rpc service")
return parser.parse_args() return parser.parse_args()
......
...@@ -121,7 +121,10 @@ if __name__ == "__main__": ...@@ -121,7 +121,10 @@ if __name__ == "__main__":
if len(gpu_ids) > 0: if len(gpu_ids) > 0:
web_service.set_gpus(gpu_ids) web_service.set_gpus(gpu_ids)
web_service.prepare_server( web_service.prepare_server(
workdir=args.workdir, port=args.port, device=args.device) workdir=args.workdir,
port=args.port,
inner_port=args.inner_port,
device=args.device)
web_service.run_rpc_service() web_service.run_rpc_service()
app_instance = Flask(__name__) app_instance = Flask(__name__)
......
...@@ -85,6 +85,7 @@ class WebService(object): ...@@ -85,6 +85,7 @@ class WebService(object):
workdir="", workdir="",
port=9393, port=9393,
device="gpu", device="gpu",
inner_port=12000,
gpuid=0, gpuid=0,
mem_optim=True, mem_optim=True,
ir_optim=False): ir_optim=False):
...@@ -93,7 +94,7 @@ class WebService(object): ...@@ -93,7 +94,7 @@ class WebService(object):
self.device = device self.device = device
self.gpuid = gpuid self.gpuid = gpuid
self.port_list = [] self.port_list = []
default_port = 12000 default_port = inner_port
for i in range(1000): for i in range(1000):
if self.port_is_available(default_port + i): if self.port_is_available(default_port + i):
self.port_list.append(default_port + i) self.port_list.append(default_port + i)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册