4 $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14 :storage => File.join('.', 'tmp', 'rots'),
15 :config => <<-DEFAULT_CONFIG
16 # Default configuration file
28 opts = OptionParser.new do |opts|
29 opts.banner = "Usage: rots [options]"
32 opts.separator "Options:"
34 opts.on("-p", "--port PORT",
35 "use PORT (default: 1123)") do |port|
36 server_options[:port] = port
39 opts.on("-s", "--storage PATH",
40 "use PATH as the OpenID Server storage path (default: ./tmp/rots)") do |storage_path|
41 server_options[:storage] = storage_path
44 opts.on("-c", "--config FILE.yaml",
45 "server configuration YAML file") do |config_path|
46 abort "\x1B[31mConfiguration file #{config_path} not found\x1B[0m" unless File.exists?(config_path)
47 server_options[:config] = File.new(config_path)
50 opts.on("-s", "--silent",
51 "If specified, the server will be in silent mode") do
52 server_options[:verbose] = false
55 opts.on("-d", "--debugger") do
56 server_options[:debugger] = true
60 opts.separator "Common options:"
62 opts.on_tail("-h", "--help", "Show this help message") do
71 config = YAML.load(server_options[:config])
73 require "ruby-debug" if server_options[:debugger]
75 server = Rack::Builder.new do
77 if server_options[:verbose]
78 use Rack::CommonLogger, STDOUT
79 use Rack::ShowExceptions
81 map ("/%s" % config['identity']) do
82 run Rots::IdentityPageApp.new(config, server_options)
85 run Rots::ServerApp.new(config, server_options)
89 puts "\x1B[32mRunning OpenID Test server on port 1123\x1B[0m" if server_options[:verbose]
91 Rack::Handler::Mongrel.run server, :Port => server_options[:port]
93 Rack::Handler::WEBrick.run server, :Port => server_options[:port]