From 7b21078344ab82fda38d42176589d32b022b5e62 Mon Sep 17 00:00:00 2001 From: Esa-Matti Suuronen Date: Fri, 22 Jul 2011 09:35:32 +0300 Subject: [PATCH] Add timer for running intervalled jobs. --- lib/watcher.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/watcher.coffee b/lib/watcher.coffee index 003f95e..e431efe 100644 --- a/lib/watcher.coffee +++ b/lib/watcher.coffee @@ -37,6 +37,7 @@ class Watcher extends EventEmitter @lastRunTimeStamp = 0 @rerun = false @running = false + @timer = null @exitstatus = 0 @status = "start" @@ -77,6 +78,15 @@ class Watcher extends EventEmitter timeSinceLastrun = ((new Date()).getTime() - @lastRunTimeStamp) / 1000 / 60 if timeSinceLastrun < @settings.interval console.log "#{ @name } got change on #{ filepath }, but interval is not due yet. #{ @settings.interval - timeSinceLastrun } minutes left" + + if not @timer + console.log "Setting timer", @name + @timer = setTimeout => + console.log "Manual run from timer", @name + @onModified filepath, True + @timer = null + , @settings.interval * 60 * 1000 + return else console.log "#{ @name } got change on #{ filepath }"