hide kqueue tests from linux
[god.git] / lib / god / server.rb
blobbcdc64821925bf08081d53e4a62e6c6d428806d1
1 require 'drb'
2 require 'drb/acl'
4 # The God::Server oversees the DRb server which dishes out info on this God daemon.
6 module God
8   class Server
9     attr_reader :host, :port
11     def initialize(host = nil, port = nil, allow = [])
12       @host = host
13       @port = port
14       @acl = %w{deny all} + allow.inject([]) { |acc, a| acc + ['allow', a] }
15       puts "Starting on #{@host}:#{@port}"
16       start
17     end
19     def ping
20       true
21     end
22     
23     def method_missing(*args, &block)
24       God.send(*args, &block)
25     end
27     private
29     def start
30       acl = ACL.new(@acl)
31       DRb.install_acl(acl)
32       
33       @drb ||= DRb.start_service("druby://#{@host}:#{@port}", self) 
34     end
35   end
37 end