2009-07-27 19:25:32 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
2009-10-01 17:26:39 -04:00
|
|
|
require 'optparse'
|
|
|
|
|
2009-10-15 19:31:05 -04:00
|
|
|
# Require Middleman
|
|
|
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
|
|
|
|
|
2009-10-15 17:24:00 -04:00
|
|
|
env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
|
2009-10-15 14:07:08 -04:00
|
|
|
options = { :Port => 4567, :Host => 'localhost', :AccessLog => [] }
|
2009-10-01 17:26:39 -04:00
|
|
|
|
2009-10-15 14:07:08 -04:00
|
|
|
OptionParser.new { |opts|
|
|
|
|
opts.banner = "Usage: mm-server [rack options]"
|
|
|
|
opts.separator ""
|
|
|
|
opts.separator "Rack options:"
|
|
|
|
opts.on("-p", "--port PORT", "use PORT (default: 4567)") { |port|
|
|
|
|
options[:Port] = port
|
|
|
|
}
|
|
|
|
opts.on("-E", "--env ENVIRONMENT", "use ENVIRONMENT for defaults (default: development)") { |e|
|
|
|
|
env = e
|
|
|
|
}
|
2009-10-15 19:31:05 -04:00
|
|
|
opts.on("--debug", "Debug mode") {
|
|
|
|
::Middleman::Base.set :logging, true
|
|
|
|
}
|
2009-10-15 14:07:08 -04:00
|
|
|
|
|
|
|
opts.parse! ARGV
|
|
|
|
}
|
|
|
|
|
2009-10-15 17:24:00 -04:00
|
|
|
ENV['RACK_ENV'] = env
|
2009-10-15 14:07:08 -04:00
|
|
|
|
2009-10-15 17:24:00 -04:00
|
|
|
class Middleman::Base
|
|
|
|
set :root, Dir.pwd
|
2009-10-15 14:07:08 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
require 'shotgun'
|
|
|
|
config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
|
2009-10-15 19:31:05 -04:00
|
|
|
app = Shotgun.new(config, lambda { |inner_app| Middleman::Base })
|
2009-10-15 14:07:08 -04:00
|
|
|
|
2009-10-15 17:24:00 -04:00
|
|
|
require 'thin'
|
2009-10-15 14:07:08 -04:00
|
|
|
Thin::Logging.silent = true
|
|
|
|
|
|
|
|
Rack::Handler::Thin.run app, options do |inst|
|
|
|
|
puts "== The Middleman is standing watch on port #{options[:Port]}"
|
2009-10-01 17:26:39 -04:00
|
|
|
end
|