class Padrino::Cli::Launcher

Protected Class Methods

exit_on_failure?() click to toggle source
# File lib/padrino-core/cli/launcher.rb, line 98
def self.exit_on_failure?
  true
end

Public Instance Methods

start(*args) click to toggle source
# File lib/padrino-core/cli/launcher.rb, line 22
def start(*args)
  prepare :start
  require File.expand_path("../adapter", __FILE__)
  require File.expand_path('config/boot.rb')

  if options[:server_options]
    puts server_options(options)
  else
    Padrino::Cli::Adapter.start(args.last ? options.merge(:config => args.last).freeze : options)
  end
end
stop() click to toggle source
# File lib/padrino-core/cli/launcher.rb, line 37
def stop
  prepare :stop
  require File.expand_path("../adapter", __FILE__)
  Padrino::Cli::Adapter.stop(options)
end

Protected Instance Methods

chdir(dir) click to toggle source
# File lib/padrino-core/cli/launcher.rb, line 87
def chdir(dir)
  return unless dir
  begin
    Dir.chdir(dir.to_s)
  rescue Errno::ENOENT
    puts "=> Specified Padrino root '#{dir}' does not appear to exist!"
  rescue Errno::EACCES
    puts "=> Specified Padrino root '#{dir}' cannot be accessed by the current user!"
  end
end
prepare(task) click to toggle source
# File lib/padrino-core/cli/launcher.rb, line 70
def prepare(task)
  if options.help?
    help(task.to_s)
    exit
  end
  if options.environment
    ENV["RACK_ENV"] = options.environment.to_s
  else
    ENV["RACK_ENV"] ||= 'development'
  end
  chdir(options.chdir)
  unless File.exist?('config/boot.rb')
    puts "=> Could not find boot file in: #{options.chdir}/config/boot.rb !!!"
    abort
  end
end

Private Instance Methods

server_options(options) click to toggle source

github.com/rack/rack/blob/master/lib/rack/server.rb#L100

# File lib/padrino-core/cli/launcher.rb, line 46
def server_options(options)
  begin
    info = []
    server = Rack::Handler.get(options[:server]) || Rack::Handler.default(options)
    if server && server.respond_to?(:valid_options)
      info << ""
      info << "Server-specific options for #{server.name}:"

      has_options = false
      server.valid_options.each do |name, description|
        next if name.to_s.match(/^(Host|Port)[^a-zA-Z]/) # ignore handler's host and port options, we do our own.
        info << "  -O %-21s %s" % [name, description]
        has_options = true
      end
      return "" if !has_options
    end
    info.join("\n")
  rescue NameError
    return "Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options"
  end
end