4 $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
15 :storage => File.join('.', 'tmp', 'rots'),
16 :config => <<-DEFAULT_CONFIG
17 # Default configuration file
29 opts = OptionParser.new do |opts|
30 opts.banner = "Usage: rots [options]"
33 opts.separator "Options:"
35 opts.on("-p", "--port PORT",
36 "use PORT (default: 1123)") do |port|
37 server_options[:port] = port
40 opts.on("-s", "--storage PATH",
41 "use PATH as the OpenID Server storage path (default: ./tmp/rots)") do |storage_path|
42 server_options[:storage] = storage_path
45 opts.on("-c", "--config FILE.yaml",
46 "server configuration YAML file") do |config_path|
47 abort "\x1B[31mConfiguration file #{config_path} not found\x1B[0m" unless File.exists?(config_path)
48 server_options[:config] = File.new(config_path)
51 opts.on("-s", "--silent",
52 "If specified, the server will be in silent mode") do
53 server_options[:verbose] = false
56 opts.on("-d", "--debugger") do
57 server_options[:debugger] = true
61 opts.separator "Common options:"
63 opts.on_tail("-h", "--help", "Show this help message") do
72 config = YAML.load(server_options[:config])
74 require "ruby-debug" if server_options[:debugger]
76 server = Rack::Builder.new do
78 if server_options[:verbose]
79 use Rack::CommonLogger, STDOUT
80 use Rack::ShowExceptions
82 map ("/%s" % config['identity']) do
83 run Rots::IdentityPageApp.new(config, server_options)
86 run Rots::ServerApp.new(config, server_options)
90 puts "\x1B[32mRunning OpenID Test server on port 1123\x1B[0m" if server_options[:verbose]
92 Rack::Handler::Mongrel.run server, :Port => server_options[:port]
94 Rack::Handler::WEBrick.run server, :Port => server_options[:port]