class Qwik::WatchLog

Public Class Methods

main(args) click to toggle source
# File vendor/qwik/lib/qwik/qwikweb-watchlog.rb, line 12
def self.main(args)
  config = Config.new
  Config.load_args_and_config(config, 'qwikweb-watchlog', args)
  self.new(config).run
end
new(config) click to toggle source
# File vendor/qwik/lib/qwik/qwikweb-watchlog.rb, line 18
def initialize(config)
  @config = config
end

Public Instance Methods

run() click to toggle source

colinux:9190/qtest/

# File vendor/qwik/lib/qwik/qwikweb-watchlog.rb, line 23
def run
  pid_path = @config.web_pid_file.path
  if pid_path.exist?
    str = pid_path.read
    puts 'Process id: '+str
  end

  p error_log = @config.log_dir.path + Logger::WEB_ERROR_LOG
  p access_log = @config.log_dir.path + Logger::ACCESS_LOG
  p web_access_log = @config.log_dir.path + Logger::WEB_ACCESS_LOG

  t1 = start_tail_f(error_log.to_s)
  t2 = start_tail_f(web_access_log.to_s)
  loop { sleep 1 }
end
start_tail_f(file) click to toggle source
# File vendor/qwik/lib/qwik/qwikweb-watchlog.rb, line 39
def start_tail_f(file)
  return Thread.new {
    open(file) {|log|
      log.seek(0, IO::SEEK_END)
      tail_f(log) {|line| puts line }
    }
  }
end
tail_f(input) { |line| ... } click to toggle source
# File vendor/qwik/lib/qwik/qwikweb-watchlog.rb, line 48
def tail_f(input)
  loop {
    line = input.gets
    yield line if line
    if input.eof?
      sleep 1
      input.seek(input.tell)
    end
  }
end