mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
61 lines
No EOL
1.6 KiB
Ruby
Executable file
61 lines
No EOL
1.6 KiB
Ruby
Executable file
#!/usr/bin/env ruby
|
|
|
|
# Non-blocking site rebuilding
|
|
trap("TSTP") do
|
|
fork do
|
|
require "open3"
|
|
first_run = true
|
|
Open3.popen3(%Q{cd "#{Dir.pwd}" && #{File.join(File.dirname(__FILE__), "mm-build")} | grep FORCED}) do |stdin, stdout, stderr|
|
|
puts "\n== Building the site..."
|
|
stdout.readlines.each do |l|
|
|
puts "== Updated:" if first_run
|
|
puts " " + l.split("[FORCED]").last.chomp
|
|
first_run = false
|
|
end
|
|
puts "== Build complete"
|
|
end
|
|
end
|
|
end
|
|
|
|
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::Server.set :logging, true
|
|
}
|
|
|
|
opts.parse! ARGV
|
|
}
|
|
|
|
ENV['RACK_ENV'] = env
|
|
|
|
class Middleman::Server
|
|
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::Server })
|
|
|
|
require 'rubygems'
|
|
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 |