No error on startup, so ACK.  Of course more needs to be done to make sure to log useful events, but as discussed, that will be in a separate patch.<br><br><div class="gmail_quote">On Mon, Feb 16, 2009 at 2:48 PM, Ian Main <span dir="ltr"><<a href="mailto:imain@redhat.com">imain@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">This patch makes taskomatic keep trying to connect to qpidd in the<br>
event of any kind of failure to do so or if the connection is lost<br>
during runtime.<br>
<br>
If others test this and it works out ok I'll do the same for<br>
dbomatic.<br>
<br>
Signed-off-by: Ian Main <<a href="mailto:imain@redhat.com">imain@redhat.com</a>><br>
---<br>
 src/task-omatic/taskomatic.rb |   44 ++++++++++++++++++++++++++++++++++++----<br>
 1 files changed, 39 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/task-omatic/taskomatic.rb b/src/task-omatic/taskomatic.rb<br>
index e65db08..a5cf6ed 100755<br>
--- a/src/task-omatic/taskomatic.rb<br>
+++ b/src/task-omatic/taskomatic.rb<br>
@@ -47,11 +47,7 @@ class TaskOmatic<br>
     @nth_host = 0<br>
<br>
     @session = Qpid::Qmf::Session.new()<br>
-<br>
-    server, port = get_srv('qpidd', 'tcp')<br>
-    raise "Unable to determine qpid server from DNS SRV record" if not server<br>
-<br>
-    @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism => 'GSSAPI')<br>
+    @broker = nil<br>
<br>
     do_daemon = true<br>
<br>
@@ -87,6 +83,42 @@ class TaskOmatic<br>
       $stdout = lf<br>
       $stderr = lf<br>
     end<br>
+<br>
+    # this has to be after daemonizing now because it could take a LONG time to<br>
+    # actually connect if qpidd isn't running yet etc.<br>
+    qpid_ensure_connected<br>
+<br>
+  end<br>
+<br>
+  def qpid_ensure_connected()<br>
+<br>
+    return if @broker and @broker.connected?<br>
+<br>
+    sleepy = 2<br>
+<br>
+    while true do<br>
+      begin<br>
+        server, port = get_srv('qpidd', 'tcp')<br>
+        raise "Unable to determine qpid server from DNS SRV record" if not server<br>
+<br>
+        @broker = @session.add_broker("amqp://#{server}:#{port}", :mechanism => 'GSSAPI')<br>
+<br>
+        # Connection succeeded, go about our business.<br>
+        return<br>
+      rescue Exception => msg<br>
+        puts "Error connecting to qpidd: #{msg}"<br>
+      end<br>
+      sleep(sleepy)<br>
+      sleepy *= 2<br>
+      sleepy = 120 if sleepy > 120<br>
+<br>
+      begin<br>
+        # Could also be a credentials problem?  Try to get them again..<br>
+        get_credentials('qpidd')<br>
+      rescue Exception => msg<br>
+        puts "Error getting qpidd credentials: #{msg}"<br>
+      end<br>
+    end<br>
   end<br>
<br>
   def find_capable_host(db_vm)<br>
@@ -755,6 +787,8 @@ class TaskOmatic<br>
         end<br>
       end<br>
<br>
+      qpid_ensure_connected<br>
+<br>
       tasks.each do |task|<br>
<br>
         task.time_started = Time.now<br>
<font color="#888888">--<br>
1.6.0.6<br>
<br>
_______________________________________________<br>
Ovirt-devel mailing list<br>
<a href="mailto:Ovirt-devel@redhat.com">Ovirt-devel@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/ovirt-devel" target="_blank">https://www.redhat.com/mailman/listinfo/ovirt-devel</a><br>
</font></blockquote></div><br>