Write a PID file 45/35645/1
authorasteroide <thomas.duval@orange.com>
Thu, 18 May 2017 13:32:57 +0000 (15:32 +0200)
committerasteroide <thomas.duval@orange.com>
Thu, 18 May 2017 13:32:57 +0000 (15:32 +0200)
Change-Id: I28f014a90c891db07d359d111b17817b65fa84b5

moonv4/moon_orchestrator/moon_orchestrator/server.py

index e6d28c2..959375b 100644 (file)
@@ -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()