MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / stop_serving

Function stop_serving

python/paddle_serving_server/serve.py:603–652  ·  view source on GitHub ↗

Stop PaddleServing by port. Args: command(str): stop->SIGINT, kill->SIGKILL port(int): Default to None, kill all processes in ProcessInfo.json. Not None, kill the specific process relating to port Returns: True if stop serving successfully.

(command: str, port: int=None)

Source from the content-addressed store, hash-verified

601
602
603def stop_serving(command: str, port: int=None):
604 '''
605 Stop PaddleServing by port.
606
607 Args:
608 command(str): stop->SIGINT, kill->SIGKILL
609 port(int): Default to None, kill all processes in ProcessInfo.json.
610 Not None, kill the specific process relating to port
611
612 Returns:
613 True if stop serving successfully.
614 False if error occured
615
616 Examples:
617 .. code-block:: python
618
619 stop_serving("stop", 9494)
620 '''
621 filepath = os.path.join(CONF_HOME, "ProcessInfo.json")
622 infoList = load_pid_file(filepath)
623 if infoList is False:
624 return False
625 lastInfo = infoList[-1]
626 for info in infoList:
627 storedPort = info["port"]
628 pid = info["pid"]
629 model = info["model"]
630 start_time = info["start_time"]
631 if port is not None:
632 if port in storedPort:
633 kill_stop_process_by_pid(command, pid)
634 infoList.remove(info)
635 if len(infoList):
636 with open(filepath, "w") as fp:
637 json.dump(infoList, fp)
638 else:
639 os.remove(filepath)
640 return True
641 else:
642 if lastInfo == info:
643 raise ValueError(
644 "Please confirm the port [%s] you specified is correct."
645 % port)
646 else:
647 pass
648 else:
649 kill_stop_process_by_pid(command, pid)
650 if lastInfo == info:
651 os.remove(filepath)
652 return True
653
654
655class Check_Env_Shell(cmd.Cmd):

Callers 1

serve.pyFile · 0.85

Calls 4

load_pid_fileFunction · 0.85
kill_stop_process_by_pidFunction · 0.85
joinMethod · 0.80
dumpMethod · 0.80

Tested by

no test coverage detected