def start_multi_app_with_file(configs): port = configs.get("port", 8866) if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False workers = configs.get("workers", number_of_workers()) options = {"bind": "0.0.0.0:%s" % port, "workers": workers} StandaloneApplication( app.create_app(init_flag=False, configs=configs), options).run() print("PaddleHub-Serving has been stopped.")
def start_app_with_args(self, workers): module = self.args.modules if module is not None: port = self.args.port if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False self.preinstall_modules() options = {"bind": "0.0.0.0:%s" % port, "workers": workers} self.dump_pid_file() StandaloneApplication( app.create_app(init_flag=False, configs=self.modules_info), options).run() else: print("Lack of necessary parameters!")
def start_multi_app_with_args(self): module = self.args.modules if module is not None: port = self.args.port workers = number_of_workers() if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False self.preinstall_modules() options = {"bind": "0.0.0.0:%s" % port, "workers": workers} configs = {"modules_info": self.module_info} StandaloneApplication( app.create_app(init_flag=False, configs=configs), options).run() print("PaddleHub Serving has been stopped.") else: print("Lack of necessary parameters!")
def start_app_with_file(self): port = self.args.config.get("port", 8866) self.args.port = port if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False self.modules_info = self.args.config.get("modules_info") self.preinstall_modules() options = { "bind": "0.0.0.0:%s" % port, "workers": self.args.workers, "pid": "./pid.txt" } self.dump_pid_file() StandaloneApplication( app.create_app(init_flag=False, configs=self.modules_info), options).run()
def start_app_with_file(self, configs, workers): port = configs.get("port", 8866) if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False modules = configs.get("modules_info") module = [str(i["module"]) + "==" + str(i["version"]) for i in modules] module_info = ServingCommand.preinstall_modules(module) for index in range(len(module_info)): modules[index].update(module_info[index]) options = { "bind": "0.0.0.0:%s" % port, "workers": workers, "pid": "./pid.txt" } configs["modules_info"] = modules self.dump_pid_file() StandaloneApplication(app.create_app(init_flag=False, configs=configs), options).run()
def start_app_with_args(self, workers): module = self.args.modules if module is not None: use_gpu = self.args.use_gpu port = self.args.port if ServingCommand.is_port_occupied("127.0.0.1", port) is True: print("Port %s is occupied, please change it." % port) return False module_info = ServingCommand.preinstall_modules(module) [ item.update({ "batch_size": 1, "queue_size": 20 }) for item in module_info ] options = {"bind": "0.0.0.0:%s" % port, "workers": workers} configs = {"use_gpu": use_gpu, "modules_info": module_info} self.dump_pid_file() StandaloneApplication( app.create_app(init_flag=False, configs=configs), options).run() else: print("Lack of necessary parameters!")