From 6ae98bfe990572180b7a09fa56064490b04f5f1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20de=20Saint=20Martin?= <cedric.dsm@tiolive.com>
Date: Thu, 29 Aug 2013 19:26:52 +0000
Subject: [PATCH] Resiliency: Use new pidfile option.

---
 slapos/recipe/notifier.py              | 4 +++-
 stack/resilient/buildout.cfg           | 2 +-
 stack/resilient/pbsready-export.cfg.in | 7 +++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/slapos/recipe/notifier.py b/slapos/recipe/notifier.py
index 0eb95401..246fc4cb 100644
--- a/slapos/recipe/notifier.py
+++ b/slapos/recipe/notifier.py
@@ -64,7 +64,7 @@ class Callback(GenericBaseRecipe):
 class Notify(GenericBaseRecipe):
 
   def createNotifier(self, notifier_binary, wrapper, executable,
-                     log, title, notification_url, feed_url):
+                     log, title, notification_url, feed_url, pidfile=None):
 
     if not os.path.exists(log):
       # Just a touch
@@ -82,6 +82,7 @@ class Notify(GenericBaseRecipe):
     return self.createWrapper(name=wrapper,
                               command=notifier_binary,
                               parameters=parameters,
+                              pidfile=pidfile,
                               comments=[
                                   '',
                                   'Call an executable and send notification(s).',
@@ -101,6 +102,7 @@ class Notify(GenericBaseRecipe):
                                  executable=options['executable'],
                                  log=log,
                                  title=options['title'],
+                                 pidfile=options['pidfile'],
                                  notification_url=options['notify'],
                                  feed_url=feed_url)
     return [script]
diff --git a/stack/resilient/buildout.cfg b/stack/resilient/buildout.cfg
index 8f4e5f8f..bbaa549d 100644
--- a/stack/resilient/buildout.cfg
+++ b/stack/resilient/buildout.cfg
@@ -48,7 +48,7 @@ mode = 0644
 recipe = slapos.recipe.template
 url = ${:_profile_base_location_}/pbsready-export.cfg.in
 output = ${buildout:directory}/pbsready-export.cfg
-md5sum = ef3861861746d3574f39f1aa3200d74e
+md5sum = 5e27c391ceafb6a58032f1f87fba7826
 mode = 0644
 
 [template-pull-backup]
diff --git a/stack/resilient/pbsready-export.cfg.in b/stack/resilient/pbsready-export.cfg.in
index e0ee258b..712c44d2 100644
--- a/stack/resilient/pbsready-export.cfg.in
+++ b/stack/resilient/pbsready-export.cfg.in
@@ -19,6 +19,12 @@ parts =
 
   cron-entry-backup
 
+[resilient-directory]
+recipe = slapos.cookbook:mkdirectory
+home = $${buildout:directory}
+var = $${:home}/var
+pid = $${:var}/pid
+
 [resilient-publish-connection-parameter]
 notification-id = http://[$${notifier:host}]:$${notifier:port}/get/$${notifier-exporter:name}
 
@@ -32,6 +38,7 @@ title = Dumping $${slap-parameter:namebase}
 executable = $${exporter:wrapper}
 wrapper = $${rootdirectory:bin}/exporter
 notify = $${slap-parameter:notify}
+pidfile = $${resilient-directory:pid}/$${:name}.pid
 
 [cron-entry-backup]
 # Schedule the periodic database dump.
-- 
2.30.9