From: asteroide Date: Thu, 18 May 2017 13:32:57 +0000 (+0200) Subject: Write a PID file X-Git-Tag: opnfv-5.1.RC1~80 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F35645%2F1;p=moon.git Write a PID file Change-Id: I28f014a90c891db07d359d111b17817b65fa84b5 --- diff --git a/moonv4/moon_orchestrator/moon_orchestrator/server.py b/moonv4/moon_orchestrator/moon_orchestrator/server.py index e6d28c23..959375be 100644 --- a/moonv4/moon_orchestrator/moon_orchestrator/server.py +++ b/moonv4/moon_orchestrator/moon_orchestrator/server.py @@ -104,8 +104,16 @@ def _exit(exit_number=0, docker=None, error=None): sys.exit(exit_number) +def __save_pid(): + try: + open("/var/run/moon_orchestrator.pid", "w").write(str(os.getpid())) + except PermissionError: + LOG.warning("You don't have the right to write PID file in /var/run... Continuing anyway.") + + def main(): # conf_file = options.configure(DOMAIN) + __save_pid() LOG.info("Starting server with IP {}".format(CONF.orchestrator.host)) docker_manager = DockerManager()