0
+ :adapter => 'mongrel',
0
+ :cache_templates => false,
0
+ :merb_root => Dir.pwd,
0
+ :session_id_cookie_only => true,
0
+ :query_string_whitelist => [],
0
+ :mongrel_x_sendfile => true
0
+ (@configuration||={})[key]
0
+ @configuration[key] = val
0
+ @configuration.delete key
0
+ def fetch(key, default)
0
+ @configuration.fetch key, default
0
+ @configuration.to_yaml
0
+ def setup(global_merb_yml = nil)
0
+ if FileTest.exist? "#{defaults[:merb_root]}/framework"
0
+ $LOAD_PATH.unshift( "#{defaults[:merb_root]}/framework" )
0
+ global_merb_yml ||= "#{defaults[:merb_root]}/config/merb.yml"
0
+ apply_configuration_from_file defaults, global_merb_yml
0
+ def apply_configuration_from_file(configuration, file)
0
+ configuration.merge(Erubis.load_yaml_file(file))
0
+ def parse_args(argv = ARGV)
0
+ # Our primary configuration hash for the length of this method
0
+ # Environment variables always win
0
+ options[:environment] = ENV['MERB_ENV'] if ENV['MERB_ENV']
0
+ # Build a parser for the command line arguments
0
+ opts = OptionParser.new do |opts|
0
+ opts.version = Merb::VERSION
0
+ opts.banner = "Usage: merb [fdcepghmisluMG] [argument]"
0
+ opts.define_head "Merb Mongrel+ Erb. Lightweight replacement for ActionPack."
0
+ opts.separator 'If no flags are given, Merb starts in the foreground on port 4000.'
0
+ opts.on("-u", "--user USER", "This flag is for having merb run as a user other than the one currently logged in. Note: if you set this you must also provide a --group option for it to take effect.") do |config|
0
+ options[:user] = config
0
+ opts.on("-G", "--group GROUP", "This flag is for having merb run as a group other than the one currently logged in. Note: if you set this you must also provide a --user option for it to take effect.") do |config|
0
+ options[:group] = config
0
+ opts.on("-f", "--config-file FILENAME", "This flag is for adding extra config files for things like the upload progress module.") do |config|
0
+ options[:config] = config
0
+ opts.on("-d", "--daemonize", "This will run a single merb in the background.") do |config|
0
+ options[:daemonize] = true
0
+ opts.on("-c", "--cluster-nodes NUM_MERBS", "Number of merb daemons to run.") do |nodes|
0
+ options[:cluster] = nodes
0
+ opts.on("-p", "--port PORTNUM", "Port to run merb on, defaults to 4000.") do |port|
0
+ opts.on("-h", "--host HOSTNAME", "Host to bind to (default is all IP's).") do |host|
0
+ opts.on("-m", "--merb-root Merb.root", "The path to the Merb.root for the app you want to run (default is current working dir).") do |root|
0
+ options[:merb_root] = File.expand_path(root)
0
+ opts.on("-a", "--adapter mongrel", "The rack adapter to use to run merb[mongrel, emongrel, thin, fastcgi, webrick]") do |adapter|
0
+ options[:adapter] = adapter
0
+ opts.on("-i", "--irb-console", "This flag will start merb in irb console mode. All your models and other classes will be available for you in an irb session.") do |console|
0
+ ::Merb::BootLoader.initialize_merb
0
+ include Merb::GeneralControllerMixin
0
+ def self.show_routes(all_opts = false)
0
+ unless Merb::Router.named_routes.empty?
0
+ Merb::Router.named_routes.each do |name,route|
0
+ puts " #{name}: #{route}"
0
+ puts "Anonymous Routes"
0
+ (Merb::Router.routes - seen).each do |route|
0
+ Object.send(:define_method, :merb) {
0
+ ARGV.clear # Avoid passing args to IRB
0
+ require 'irb/completion'
0
+ if File.exists? ".irbrc"
0
+ ENV['IRBRC'] = ".irbrc"
0
+ opts.on("-s", "--start-drb PORTNUM", "This is the port number to run the drb daemon on for sessions and upload progress monitoring.") do |drb_port|
0
+ puts "Starting merb drb server on port: #{Merb::Config[:drb_server_port]}"
0
+ Merb::Server.start(drb_port, :drbserver_start)
0
+ exit if Merb::Config[:only_drb]
0
+ opts.on("-l", "--log-level LEVEL", "Log levels can be set to any of these options: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN") do |loglevel|
0
+ options[:log_level] = loglevel
0
+ opts.on("-e", "--environment STRING", "Run merb in the correct mode(development, production, testing)") do |env|
0
+ options[:environment] ||= env
0
+ opts.on("-r", "--script-runner ['RUBY CODE'| FULL_SCRIPT_PATH]",
0
+ "Command-line option to run scripts and/or code in the merb app.") do |code_or_file|
0
+ ::Merb::BootLoader.initialize_merb
0
+ if File.exists?(code_or_file)
0
+ eval(File.read(code_or_file))
0
+ opts.on("-P","--generate-plugin PATH", "Generate a fresh merb plugin at PATH.") do |path|
0
+ require 'merb/generators/merb_plugin'
0
+ ::Merb::PluginGenerator.run path || Dir.pwd
0
+ opts.on("-K", "--graceful PORT or all", "Gracefully kill one merb proceses by port number. Use merb -K all to gracefully kill all merbs.") do |ports|
0
+ @configuration = defaults.merge(options)
0
+ Merb::Server.kill(ports, 1)
0
+ opts.on("-k", "--kill PORT or all", "Kill one merb proceses by port number. Use merb -k all to kill all merbs.") do |ports|
0
+ @configuration = defaults.merge(options)
0
+ Merb::Server.kill(ports, 9)
0
+ opts.on("-M", "--merb-config FILENAME", "This flag is for explicitly declaring the merb app's config file.") do |config|
0
+ options[:merb_config] = config
0
+ opts.on("-w", "--webrick", "Run merb using Webrick Rack Adapter instead of mongrel.") do |webport|
0
+ puts "Starting merb webrick server on port: #{Merb::Config[:port]}"
0
+ Merb::Server.webrick_start(Merb::Config[:port])
0
+ opts.on("-F", "--fastcgi", "Run merb using FastCGI Rack Adapter instead of mongrel.") do
0
+ Merb::Server.fastcgi_start
0
+ opts.on("-X", "--mutex on/off", "This flag is for turning the mutex lock on and off.") do |mutex|
0
+ options[:use_mutex] = false
0
+ options[:use_mutex] = true
0
+ opts.on("-D", "--debugger", "Run merb using rDebug.") do
0
+ Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
0
+ puts "Debugger enabled"
0
+ puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'"
0
+ opts.on("-?", "-H", "--help", "Show this help message") do
0
+ # If we run merb with no arguments and we are not inside a merb root
0
+ # show the help message
0
+ if !defined?(Merb.framework_root) && (argv.size == 0) && !File.exists?("#{options[:merb_root] || Merb::Config.defaults[:merb_root]}/config/merb_init.rb")
0
+ puts "You are not in the root of a merb application...\n"
0
+ # Parse what we have on the command line
0
+ # merb <argument> is same as merb -g <argument>
0
+ require 'merb/generators/merb_app/merb_app'
0
+ ::Merb::AppGenerator.run File.expand_path(argv.last)
0
+ # Load up the configuration from file, but keep the command line
0
+ # options that may have been chosen. Also, pass-through if we have
0
+ # a new merb_config path.
0
+ options = Merb::Config.setup(options[:merb_config]).merge(options)
0
+ # Finally, if all else fails... set the environment to 'development'
0
+ options[:environment] ||= 'development'
0
+ environment_merb_yml = "#{options[:merb_root]}/config/environments/#{options[:environment]}.yml"
0
+ @configuration = Merb::Config.apply_configuration_from_file options, environment_merb_yml
0
+ case Merb::Config[:environment].to_s
0
+ Merb::Config[:reloader] = Merb::Config.fetch(:reloader, false)
0
+ Merb::Config[:exception_details] = Merb::Config.fetch(:exception_details, false)
0
+ Merb::Config[:cache_templates] = true
0
+ Merb::Config[:reloader] = Merb::Config.fetch(:reloader, true)
0
+ Merb::Config[:exception_details] = Merb::Config.fetch(:exception_details, true)
0
+ Merb::Config[:reloader_time] ||= 0.5 if Merb::Config[:reloader] == true
0
+ if Merb::Config[:reloader]
0
+ Thread.abort_on_exception = true
0
+ sleep( Merb::Config[:reloader_time] )
0
+ ::Merb::BootLoader.reload if ::Merb::BootLoader.app_loaded?
0
\ No newline at end of file