Module: LFD::Run

Included in:
App
Defined in:
lib/lfd/run.rb

Instance Method Summary collapse

Instance Method Details

#check_tracelog_configObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lfd/run.rb', line 17

def check_tracelog_config
  if File.exist?(mm_cfg)
    File.open(mm_cfg, 'r+') do |file|
      cfg = {}
      file.each do |line|
        opt = line.split('=')
        cfg[opt[0]] = opt[1].chomp
      end
      cfg["ErrorReportingEnable"]="1"
      cfg["TraceOutputFileEnable"]="1"
      str = cfg.inject("") { |s,o| "#{s}#{o[0]}=#{o[1]}\n" }
      file.rewind
      file.write str
    end
  else
    File.open(mm_cfg, 'w') do |file|
      file.puts("ErrorReportingEnable=1\nTraceOutputFileEnable=1")
    end
  end
end

#run(opt = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/lfd/run.rb', line 5

def run(opt={})
  check_tracelog_config
  empty_tracelog
  info = YAML.load_file(CONFIG_FILE)
  swf = File.expand_path(info["output"]["file"], FileUtils.pwd) 
  player = fork { exec "#{flash_player_path} #{swf} 2> /dev/null"}
  tracer = fork { exec "tail", "-f", trace_log_file }
  Process.detach tracer
  Process.wait
  Process.kill "HUP", tracer
end