catch exceptions when setting up the chargeprocessor, add run option to run without...
smbaker [Wed, 19 Sep 2012 21:49:52 +0000 (14:49 -0700)]
apps/gacks/gackscollector.py [changed mode: 0755->0644]

old mode 100755 (executable)
new mode 100644 (file)
index 860900c..9644251
@@ -227,9 +227,14 @@ class ChargeProcessor(threading.Thread):
     def run(self):
         self.log.writeTS("ChargeProcessor: starting " )
         delay = 5
-        self.account_manager = GacksAccountManager()
-        self.invoice_manager = GacksInvoiceManager(accounts=self.account_manager)
-        self.node_status = GacksNodeStatus()
+        try:
+            self.account_manager = GacksAccountManager()
+            self.invoice_manager = GacksInvoiceManager(accounts=self.account_manager)
+            self.node_status = GacksNodeStatus()
+        except:
+            self.log.writeTS(traceback.format_exc())
+            raise
+
         while True:
             try:
                 if self.host_queue.empty():
@@ -239,8 +244,8 @@ class ChargeProcessor(threading.Thread):
                     self.process_charges(host)
                     self.host_queue.task_done()
             except:
-                self.log.writeTS(traceback.format_exc())   
-        
+                self.log.writeTS(traceback.format_exc())
+
 
 class CollectWorker(threading.Thread):
 
@@ -353,6 +358,7 @@ class GacksCollector(Daemon):
 
         self.log.writeTS("GacksCollecter: starting Charge Processor" )
         self.charge_processor.start()
+        #self.charge_processor.host_queue.put("node1.princeton.vicci.org") # XXX
         while True:
             try:
                 now = time.time()
@@ -378,6 +384,8 @@ if __name__ == '__main__':
                 daemon.stop()
         elif 'restart' == sys.argv[1]:
                 daemon.restart()
+        elif 'run' == sys.argv[1]:
+                daemon.run()
         else:
                 print "Unknown command"
                 sys.exit(2)