From dfb3cafc5a3fa737ec93d820af7fca6886636fb7 Mon Sep 17 00:00:00 2001 From: asteroide Date: Thu, 18 May 2017 15:32:57 +0200 Subject: Write a PID file Change-Id: I28f014a90c891db07d359d111b17817b65fa84b5 --- moonv4/moon_orchestrator/moon_orchestrator/server.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'moonv4') 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() -- cgit 1.2.3-korg