class Server
Sinatra server to host the statistics for the CobwebCrawler
Public Class Methods
cobweb_options()
click to toggle source
# File lib/server.rb, line 106 def self.cobweb_options @options end
start(options={})
click to toggle source
Starts the Sinatra server, and kills the processes when shutdown
# File lib/server.rb, line 86 def self.start(options={}) @options = options @options[:redis_options] = {} unless @options.has_key? :redis_options unless Server.running? if @options[:run_as_server] puts "Starting Sinatra for cobweb v#{Cobweb.version}" Server.run! puts "Stopping crawl..." else thread = Thread.new do puts "Starting Sinatra" Server.run! puts "Stopping crawl..." ## we need to manually kill the main thread as sinatra traps the interrupts Thread.main.kill end end end end
Public Instance Methods
cobweb_version(crawl_id)
click to toggle source
# File lib/server.rb, line 73 def cobweb_version(crawl_id) redis = RedisConnection.new(redis_options) key = redis.keys("cobweb-*-#{crawl_id}:queued").first key =~ /cobweb-(.*?)-(.*?):queued/ cobweb_version = $1 end
redis_options()
click to toggle source
# File lib/server.rb, line 81 def redis_options Server.cobweb_options[:redis_options] end