Sha256: a47fbea5f5267e62b7000cc758c6bbcf0bd2b04ed1b4e26f7d16fcf6d8eb1510
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
module Flydata module Command class Sender < Base FLYDATA_HOME=Flydata::HOME_DIR def start if process_exist? say("Process exist. Please stop process first.") return end retry_count = 10 1.upto(retry_count) do |i| break if server_ready? say("Waiting server side active... (#{i}/#{retry_count})") sleep 30 end say('Starting sender process.') system("fluentd -d #{FLYDATA_HOME}/flydata.pid -l #{FLYDATA_HOME}/flydata.log -c #{FLYDATA_HOME}/flydata.conf") sleep 5 retry_count = 10 1.upto(retry_count) do |i| if client_ready? say('Done.') return true end say("Waiting client side active... (#{i}/#{retry_count})") sleep 30 end say('Something wrong..') end def stop say('Stopping sender process.') if system("kill `cat #{FLYDATA_HOME}/flydata.pid`") say('Done.') return true else say('Something wrong..') end end def restart say('Restarting sender process.') stop and start end private def server_ready? data_port = flydata.data_port.get data_port['server_status'] == 'active' end def client_ready? process_exist? end def process_exist? process_count = `ps aux|grep -v grep|grep "\\.flydata/"|wc -l`.to_i process_count > 0 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flydata-0.0.1.2011102301 | lib/flydata/command/sender.rb |
flydata-0.0.1.2011101801 | lib/flydata/command/sender.rb |