lib/jstd-runner.rb in jstd-runner-0.0.2 vs lib/jstd-runner.rb in jstd-runner-0.0.3
- old
+ new
@@ -1,8 +1,9 @@
require "logger"
require "optparse"
require "etc"
+require 'time'
module JstdRunner
Log = Logger.new(STDOUT)
class << self
@@ -23,5 +24,19 @@
require "jstd-runner/vnc_control"
require "jstd-runner/server"
require "jstd-runner/runner"
+module EventMachine
+ def self.daily at, &blk
+ time = Time.parse(at) - Time.now
+ time += 86400 if time < 0
+
+ EM.run do
+ run_me = proc{
+ EM.add_timer(86400, run_me)
+ blk.call
+ }
+ EM.add_timer(time, run_me)
+ end
+ end
+end
\ No newline at end of file