middleman/bin/mm-server

43 lines
1.1 KiB
Plaintext
Raw Normal View History

2009-07-28 01:25:32 +02:00
#!/usr/bin/env ruby
2009-10-01 23:26:39 +02:00
require 'optparse'
2009-10-16 01:31:05 +02:00
# Require Middleman
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
2009-10-15 23:24:00 +02:00
env = ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development'
2009-10-22 19:14:47 +02:00
options = { :Port => 4567, :AccessLog => [] }
2009-10-01 23:26:39 +02:00
2009-10-15 20:07:08 +02: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-16 01:31:05 +02:00
opts.on("--debug", "Debug mode") {
::Middleman::Base.set :logging, true
}
2009-10-15 20:07:08 +02:00
opts.parse! ARGV
}
2009-10-15 23:24:00 +02:00
ENV['RACK_ENV'] = env
2009-10-15 20:07:08 +02:00
2009-10-15 23:24:00 +02:00
class Middleman::Base
set :root, Dir.pwd
2009-10-15 20:07:08 +02:00
end
require 'shotgun'
config = File.join(File.dirname(__FILE__), '..', 'lib', 'middleman', 'config.ru')
2009-10-16 01:31:05 +02:00
app = Shotgun.new(config, lambda { |inner_app| Middleman::Base })
2009-10-15 20:07:08 +02:00
2009-10-15 23:24:00 +02:00
require 'thin'
2009-10-15 20:07:08 +02: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 23:26:39 +02:00
end