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

41 lines
1 KiB
Text
Raw Normal View History

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 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
}
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
# Require Middleman
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
2009-10-15 14:07:08 -04:00
2009-10-15 17:24:00 -04:00
class Middleman::Base
set :root, Dir.pwd
set :logging, false
2009-10-15 14:07:08 -04:00
end
require 'shotgun'
config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
2009-10-15 17:24:00 -04:00
app = Shotgun.new(config, lambda { |inner_app| Middleman::Base.new })
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