XXJ.rb
Path: main/XXJ.rb
Modified: Sun Apr 06 11:50:24 MDT 2003
Required files
optparse    shellwords    socket    util/config   
Methods
main    start   
Classes and Modules
Class XXJOpts
Public Instance methods
main(opts, args)

main(): application itself starts here.

# File main/XXJ.rb, line 56
def main(opts, args)
  named = Config.instance.named

  host = named["host"]
  port = named["port"].to_i

  running = false
  begin
    gs = TCPServer.new(host, port)
  rescue Exception => e
    running = true
    STDERR.puts(e.message)
  else
    gs.shutdown(2); gs.close
  end

  if running
    STDERR.puts("XXJ name server is already running."); exit(1)
  end

  start = Config.instance.start

  start.each {
    |prog|
    sleep(2)
    STDERR.puts("Starting '#{prog}'...")
    fork {
      exec(prog)
    }
  }

  return 0
end
start(av)

Entry point if called as executable.

# File main/XXJ.rb, line 178
def start(av)
  opts = XXJOpts.new(USAGE, BANNER)
  main(opts.vals, opts.parse(av))
end