Class GenericServer
In: srv/backendserver.rb
Parent: Object

Server class to run an object of class Player.

Methods
new    run    run_server   
Public Class methods
new(opts, rest)

Initialize instance vars.

opts
hash of options and configuration info
rest
non-option args (not used)
# File srv/backendserver.rb, line 90
  def initialize(opts, rest)
    @opts = opts
    @argv = rest
    @prefix = opts["prefix"]
    @myname = opts["myname"]
    @cmdline = opts["exec"]
  end
Public Instance methods
run_server()

Run the server process. Spawns a thread to send periodic "I'm alive" messages to queuemgr so its entry will not be garbage-collected as unreachable.

# File srv/backendserver.rb, line 101
  def run_server()
    host = @opts["host"]
    port = find_free_port(host)
    xs = XMLRPC::Server.new(port, host)
    xs.add_handler(Player.interface(@prefix),
		   Player.new(@myname, @cmdline))
    named = get_named_proxy
    named.register("player://" + @myname, [ host, port, @prefix ])
    keepalive = Thread.start(named) {
      |named|
      while true
	Thread.pass
	sleep(REGISTER_INTERVAL);
	Thread.pass
	named.register("player://" + @myname, [ host, port, @prefix ])
      end
    }
    xs.serve
    Thread.kill(keepalive)
    @player.stop
    named.unregister("player://" + @myname)
  end
run()

Daemonize and call run_server.

# File srv/backendserver.rb, line 125
  def run()
    if @opts["daemon"] != "yes"
      run_server
    else
      daemon {
	tommy_mode
	run_server; exit(0)
      }
    end # @opts["daemon"] != "yes"
    return 0
  end