Blob Blame History Raw
From ccc1006f53fa6b8506b08435bdd9e960bd696232 Mon Sep 17 00:00:00 2001
From: Alan Pevec <apevec@redhat.com>
Date: Tue, 11 Feb 2014 22:36:00 +0100
Subject: [PATCH] notify calling process we are ready to serve

Deploy systemd notifications in api, registry and scrubber services.
It does not have an effect when running the service outside
the systemd environment.

Change-Id: I80f325c9be9c171c2dc8d5526570bf64f0f87c78
---
 glance/cmd/api.py      | 2 ++
 glance/cmd/registry.py | 2 ++
 glance/cmd/scrubber.py | 2 ++
 3 files changed, 6 insertions(+)

diff --git a/glance/cmd/api.py b/glance/cmd/api.py
index 9d64c13..7e132c5 100755
--- a/glance/cmd/api.py
+++ b/glance/cmd/api.py
@@ -51,6 +51,7 @@ from glance.common import config
 from glance.common import exception
 from glance.common import wsgi
 from glance import notifier
+from oslo_service import systemd
 
 CONF = cfg.CONF
 CONF.import_group("profiler", "glance.common.wsgi")
@@ -86,6 +87,7 @@ def main():
 
         server = wsgi.Server(initialize_glance_store=True)
         server.start(config.load_paste_app('glance-api'), default_port=9292)
+        systemd.notify_once()
         server.wait()
     except KNOWN_EXCEPTIONS as e:
         fail(e)
diff --git a/glance/cmd/registry.py b/glance/cmd/registry.py
index 4e4117a..99bbc0d 100755
--- a/glance/cmd/registry.py
+++ b/glance/cmd/registry.py
@@ -47,6 +47,7 @@ import osprofiler.web
 from glance.common import config
 from glance.common import wsgi
 from glance import notifier
+from oslo_service import systemd
 
 CONF = cfg.CONF
 CONF.import_group("profiler", "glance.common.wsgi")
@@ -73,6 +74,7 @@ def main():
         server = wsgi.Server()
         server.start(config.load_paste_app('glance-registry'),
                      default_port=9191)
+        systemd.notify_once()
         server.wait()
     except RuntimeError as e:
         sys.exit("ERROR: %s" % encodeutils.exception_to_unicode(e))
diff --git a/glance/cmd/scrubber.py b/glance/cmd/scrubber.py
index 1d2fa4c..89f4be6 100755
--- a/glance/cmd/scrubber.py
+++ b/glance/cmd/scrubber.py
@@ -36,6 +36,7 @@ from oslo_config import cfg
 from oslo_log import log as logging
 
 from glance.common import config
+from oslo_service import systemd
 from glance import scrubber
 
 eventlet.patcher.monkey_patch(all=False, socket=True, time=True, select=True,
@@ -62,6 +63,7 @@ def main():
         if CONF.daemon:
             server = scrubber.Daemon(CONF.wakeup_time)
             server.start(app)
+            systemd.notify_once()
             server.wait()
         else:
             app.run()