Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add timer for running intervalled jobs.

  • Loading branch information...
commit 7b21078344ab82fda38d42176589d32b022b5e62 1 parent 5b4ee67
Esa-Matti Suuronen authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/watcher.coffee
10 lib/watcher.coffee
View
@@ -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 }"
Please sign in to comment.
Something went wrong with that request. Please try again.