Skip to content

Instantly share code, notes, and snippets.

@modeverv
Created August 9, 2011 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modeverv/1134278 to your computer and use it in GitHub Desktop.
Save modeverv/1134278 to your computer and use it in GitHub Desktop.
#! ruby
# -*- coding: utf-8 -*-
require "/Users/seijiro/code/ruby/my-lib.rb"
class ThisDo < MyObject
include RunPerSecModule
include MyDBModule
include MyPusherModule
def initialize
@f = open(ARGV[0]||"/var/log/system.log")
while @f.gets
end
@count = 1 #ループ制御
end
def main_loop
data = ""
while @f.gets
data << $_
print $_
end
kick(data) if data !=""
@count = @count + 1
puts @count
stop_run if @count > 10
end
def kick(data)
data = data.toutf8.gsub("\n","<br>")
insert_DB("my_app_tail",data)
push_pusher('my_app_tail',data)
end
end
instance = ThisDo.new
instance.run(1) do
puts "check"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment