Module: MyWorker

Defined in:
lib/daemon.rb

Instance Method Summary collapse

Instance Method Details

#reloadObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/daemon.rb', line 12

def reload
  begin
    @script = nil
    File.open(config[:script]) do |f|
      @script = Script::TopLevel.new(logger, f.read)
    end
  rescue => e
    logger.fatal "can't open script file"
    logger.fatal e.to_s
  end
end

#runObject



2
3
4
5
6
7
8
9
10
# File 'lib/daemon.rb', line 2

def run
  reload
  until @stop
    if @script
      @script.doit
    end
    sleep 1
  end
end

#stopObject



24
25
26
# File 'lib/daemon.rb', line 24

def stop
  @stop = true
end