[CalendarServer-changes] [11171] CalendarServer/trunk/txdav/base/datastore/subpostgres.py

source_changes at macosforge.org source_changes at macosforge.org
Mon May 13 12:02:29 PDT 2013


Revision: 11171
          http://trac.calendarserver.org//changeset/11171
Author:   sagen at apple.com
Date:     2013-05-13 12:02:29 -0700 (Mon, 13 May 2013)
Log Message:
-----------
Don't hang if pg_ctl fails -- exit right away.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/base/datastore/subpostgres.py

Modified: CalendarServer/trunk/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-05-11 06:09:42 UTC (rev 11170)
+++ CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-05-13 19:02:29 UTC (rev 11171)
@@ -85,13 +85,19 @@
 
 
     def processEnded(self, reason):
-        log.warn("postgres process ended %r" % (reason,))
-        result = (reason.value.status == 0)
+        log.warn("postgres process ended with status %d" % (reason.value.status,))
+        # If pg_ctl exited with zero, we were successful in starting postgres
+        # If pg_ctl exited with nonzero, we need to give up.
         self.lineReceiver.connectionLost(reason)
-        self.completionDeferred.callback(result)
 
+        if reason.value.status == 0:
+            self.completionDeferred.callback(None)
+        else:
+            log.warn("Could not start postgres; see postgres.log")
+            self.completionDeferred.errback(reason)
 
 
+
 class ErrorOutput(Exception):
     """
     The process produced some error output and exited with a non-zero exit
@@ -446,13 +452,14 @@
         )
         self.monitor = monitor
         def gotReady(result):
-            log.warn("%s successful" % (pgCtl,))
-            self.shouldStopDatabase = result
+            log.warn("%s exited" % (pgCtl,))
+            self.shouldStopDatabase = True
             self.ready(*createConnection())
             self.deactivateDelayedShutdown()
         def reportit(f):
             log.err(f)
             self.deactivateDelayedShutdown()
+            self.reactor.stop()
         self.monitor.completionDeferred.addCallback(
             gotReady).addErrback(reportit)
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130513/2d99e6ec/attachment.html>


More information about the calendarserver-changes mailing list