class StompServer::Configurator
Attributes
opts[RW]
Public Class Methods
new()
click to toggle source
# File lib/stomp_server.rb, line 20 def initialize @opts = nil @defaults = { :port => 61613, :host => "127.0.0.1", :debug => false, :queue => 'memory', :auth => false, :working_dir => Dir.getwd, :storage => ".stompserver", :logdir => 'log', :configfile => 'stompserver.conf', :logfile => 'stompserver.log', :pidfile => 'stompserver.pid', :checkpoint => 0 } @opts = getopts if opts[:debug] $DEBUG=true end end
Public Instance Methods
getopts()
click to toggle source
# File lib/stomp_server.rb, line 43 def getopts copts = OptionParser.new copts.on("-C", "--config=CONFIGFILE", String, "Configuration File (default: stompserver.conf)") {|c| @defaults[:configfile] = c} copts.on("-p", "--port=PORT", Integer, "Change the port (default: 61613)") {|p| @defaults[:port] = p} copts.on("-b", "--host=ADDR", String, "Change the host (default: localhost)") {|a| @defaults[:host] = a} copts.on("-q", "--queuetype=QUEUETYPE", String, "Queue type (memory|dbm|activerecord|file) (default: memory)") {|q| @defaults[:queue] = q} copts.on("-w", "--working_dir=DIR", String, "Change the working directory (default: current directory)") {|s| @defaults[:working_dir] = s} copts.on("-s", "--storage=DIR", String, "Change the storage directory (default: .stompserver, relative to working_dir)") {|s| @defaults[:storage] = s} copts.on("-d", "--debug", String, "Turn on debug messages") {|d| @defaults[:debug] = true} copts.on("-a", "--auth", String, "Require client authorization") {|a| @defaults[:auth] = true} copts.on("-c", "--checkpoint=SECONDS", Integer, "Time between checkpointing the queues in seconds (default: 0)") {|c| @defaults[:checkpoint] = c} copts.on("-h", "--help", "Show this message") do puts copts exit end puts copts.parse(ARGV) if File.exists?(@defaults[:configfile]) opts = @defaults.merge(YAML.load_file(@defaults[:configfile])) else opts = @defaults end opts[:etcdir] = File.join(opts[:working_dir],'etc') opts[:storage] = File.join(opts[:working_dir],opts[:storage]) opts[:logdir] = File.join(opts[:working_dir],opts[:logdir]) opts[:logfile] = File.join(opts[:logdir],opts[:logfile]) opts[:pidfile] = File.join(opts[:logdir],opts[:pidfile]) if opts[:auth] opts[:passwd] = File.join(opts[:etcdir],'.passwd') end return opts end