[CalendarServer-changes] [15620] CalendarServer/trunk/calendarserver/tools/dashcollect.py

source_changes at macosforge.org source_changes at macosforge.org
Thu May 19 17:27:35 PDT 2016


Revision: 15620
          http://trac.calendarserver.org//changeset/15620
Author:   cdaboo at apple.com
Date:     2016-05-19 17:27:35 -0700 (Thu, 19 May 2016)
Log Message:
-----------
Handle ctrl-c to stop the service.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/dashcollect.py

Modified: CalendarServer/trunk/calendarserver/tools/dashcollect.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/dashcollect.py	2016-05-19 23:32:26 UTC (rev 15619)
+++ CalendarServer/trunk/calendarserver/tools/dashcollect.py	2016-05-20 00:27:35 UTC (rev 15620)
@@ -119,7 +119,13 @@
         server_thread.daemon = True
         server_thread.start()
 
-    dash_thread.join()
+    while dash_thread.isAlive():
+        try:
+            dash_thread.join(1000)
+        except KeyboardInterrupt:
+            print("Terminating service")
+            dash.stop()
+            server.shutdown()
 
 
 
@@ -350,6 +356,7 @@
         self.sched = sched.scheduler(time.time, time.sleep)
         self.seconds = 1
         self.lastData = {}
+        self._stop = False
 
 
     def run(self):
@@ -359,8 +366,13 @@
         _verbose("Starting Dashboard")
         self.sched.enter(self.seconds, 0, self.update, ())
         self.sched.run()
+        _verbose("Stopped Dashboard")
 
 
+    def stop(self):
+        self._stop = True
+
+
     @staticmethod
     def logfile(logdir):
         """
@@ -391,7 +403,8 @@
 
         self.lastData = j
 
-        self.sched.enter(self.seconds, 0, self.update, ())
+        if not self._stop:
+            self.sched.enter(self.seconds, 0, self.update, ())
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160519/f261f8fe/attachment-0001.html>


More information about the calendarserver-changes mailing list