changeset 609:978d8bca9fb3

admin: Fix "Publish started" message showing up multiple times.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 28 Jan 2016 22:16:47 -0800
parents 8e1b38632702
children efc1dc916e7c
files foodtruck/pubutil.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/foodtruck/pubutil.py	Wed Jan 27 23:39:00 2016 -0800
+++ b/foodtruck/pubutil.py	Thu Jan 28 22:16:47 2016 -0800
@@ -29,14 +29,14 @@
 
 class PublishLogReader(object):
     _pub_max_time = 10 * 60   # Don't bother about pubs older than 10mins.
-    _poll_interval = 2        # Check the PID file every 2 seconds.
+    _poll_interval = 1        # Check the PID file every 1 seconds.
     _ping_interval = 30       # Send a ping message every 30 seconds.
 
     def __init__(self, pid_path, log_path):
         self.pid_path = pid_path
         self.log_path = log_path
         self._pub_pid_mtime = 0
-        self._last_seek = 0
+        self._last_seek = -1
         self._last_ping_time = 0
 
     def run(self):
@@ -64,9 +64,10 @@
                 # Send data.
                 new_data = None
                 if self._pub_pid_mtime > 0 or prev_mtime > 0:
-                    if self._last_seek == 0:
+                    if self._last_seek < 0:
                         outstr = 'event: message\ndata: Publish started.\n\n'
                         yield bytes(outstr, 'utf8')
+                        self._last_seek = 0
 
                     try:
                         with open(self.log_path, 'r', encoding='utf8') as fp: