public
Last active

  • Download Gist
glucose_server.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#!/usr/bin/env ruby
 
require 'drb'
require 'drb/drb'
# require 'drb/ssl'
require 'sequel'
# require 'logger'
 
$SAFE = 1 #disable eval
 
class Glucose
CURRENT_DIR = File.expand_path File.dirname(__FILE__)
LOCAL_URI="druby://10.8.0.1:8787"
 
include DRb::DRbUndumped
def initialize
# @log = LOGGER
@db = Sequel.connect(:adapter=>'mysql', :host=>'localhost', :database=>'glucose', :user=>'user', :password=>'password', :encoding => 'utf8')
@srv = DRb::start_service(LOCAL_URI,self)
@results = []
end
 
def runme
DRb::thread.join()
end
 
def make_list
n = 25 # how many words to process at each request
wordlist = Array.new
lexeisdb = @db[:lexeis].where(:web_ranking => nil)
lexeisdb.take(n).each do |entry|
w = entry[:word].force_encoding('UTF-8')
wordlist.push(w)
end
hash = {
list: wordlist,
engine: 'Google'
}
hash
end
 
def Glucose::remote
DRb.start_service(nil,nil)
DRbObject.new(nil,URI)
end
end
 
if($0==__FILE__)
Glucose::new.runme
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.