1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/bin/mm-server

43 lines
1.1 KiB
Text
Raw Normal View History

#!/usr/bin/env ruby
require 'optparse'
# Require Middleman
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
options = { :Port => 4567, :AccessLog => [] }
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
}
opts.on("--debug", "Debug mode") {
::Middleman::Base.set :logging, true
}
opts.parse! ARGV
}
ENV['RACK_ENV'] = env
class Middleman::Base
set :root, Dir.pwd
end
require 'shotgun'
config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
app = Shotgun.new(config, lambda { |inner_app| Middleman::Base })
require 'thin'
Thin::Logging.silent = true
Rack::Handler::Thin.run app, options do |inst|
puts "== The Middleman is standing watch on port #{options[:Port]}"
end