Merge pull request #665 from techthumb/master
Changed log message when middleman starts.
This commit is contained in:
commit
4ef92481af
1 changed files with 17 additions and 21 deletions
|
@ -6,17 +6,18 @@ module Middleman
|
||||||
DEFAULT_PORT = 4567
|
DEFAULT_PORT = 4567
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
attr_reader :app, :port
|
attr_reader :app, :host, :port
|
||||||
delegate :logger, :to => :app
|
delegate :logger, :to => :app
|
||||||
|
|
||||||
# Start an instance of Middleman::Application
|
# Start an instance of Middleman::Application
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def start(opts={})
|
def start(opts={})
|
||||||
@options = opts
|
@options = opts
|
||||||
|
@host = @options[:host] || Socket.gethostname
|
||||||
@port = @options[:port] || DEFAULT_PORT
|
@port = @options[:port] || DEFAULT_PORT
|
||||||
|
|
||||||
mount_instance
|
mount_instance
|
||||||
logger.info "== The Middleman is standing watch on port #{port}"
|
logger.info "== The Middleman is standing watch at http://#{host}:#{port}"
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
unless @initialized
|
unless @initialized
|
||||||
|
@ -52,11 +53,11 @@ module Middleman
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def reload
|
def reload
|
||||||
logger.info "== The Middleman is reloading"
|
logger.info "== The Middleman is reloading"
|
||||||
|
|
||||||
unmount_instance
|
unmount_instance
|
||||||
mount_instance
|
mount_instance
|
||||||
|
|
||||||
logger.info "== The Middleman is standing watch on port #{port}"
|
logger.info "== The Middleman is standing watch at http://#{host}:#{port}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Stop the current instance, exit Webrick
|
# Stop the current instance, exit Webrick
|
||||||
|
@ -73,22 +74,22 @@ module Middleman
|
||||||
if opts[:environment]
|
if opts[:environment]
|
||||||
config[:environment] = opts[:environment].to_sym
|
config[:environment] = opts[:environment].to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
|
logger(opts[:debug] ? 0 : 1, opts[:instrumenting] || false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_file_watcher
|
def start_file_watcher
|
||||||
return if @options[:"disable-watcher"]
|
return if @options[:"disable-watcher"]
|
||||||
|
|
||||||
first_run = !@listener
|
first_run = !@listener
|
||||||
|
|
||||||
if first_run
|
if first_run
|
||||||
# Watcher Library
|
# Watcher Library
|
||||||
require "listen"
|
require "listen"
|
||||||
@listener = Listen.to(Dir.pwd, :relative_paths => true)
|
@listener = Listen.to(Dir.pwd, :relative_paths => true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@listener.change do |modified, added, removed|
|
@listener.change do |modified, added, removed|
|
||||||
added_and_modified = (modified + added)
|
added_and_modified = (modified + added)
|
||||||
|
|
||||||
|
@ -125,11 +126,9 @@ module Middleman
|
||||||
|
|
||||||
# Initialize webrick
|
# Initialize webrick
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def setup_webrick(host, is_logging)
|
def setup_webrick(is_logging)
|
||||||
@host = host
|
|
||||||
|
|
||||||
http_opts = {
|
http_opts = {
|
||||||
:BindAddress => @host,
|
:BindAddress => host,
|
||||||
:Port => port,
|
:Port => port,
|
||||||
:AccessLog => []
|
:AccessLog => []
|
||||||
}
|
}
|
||||||
|
@ -154,13 +153,10 @@ module Middleman
|
||||||
def mount_instance
|
def mount_instance
|
||||||
@app = new_app
|
@app = new_app
|
||||||
|
|
||||||
@webrick ||= setup_webrick(
|
@webrick ||= setup_webrick(@options[:debug] || false)
|
||||||
@options[:host] || "0.0.0.0",
|
|
||||||
@options[:debug] || false
|
|
||||||
)
|
|
||||||
|
|
||||||
start_file_watcher
|
start_file_watcher
|
||||||
|
|
||||||
@webrick.mount "/", ::Rack::Handler::WEBrick, app.class.to_rack_app
|
@webrick.mount "/", ::Rack::Handler::WEBrick, app.class.to_rack_app
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -180,13 +176,13 @@ module Middleman
|
||||||
%r{^lib/^[^\.](.*)\.rb$},
|
%r{^lib/^[^\.](.*)\.rb$},
|
||||||
%r{^helpers/^[^\.](.*)_helper\.rb$}
|
%r{^helpers/^[^\.](.*)_helper\.rb$}
|
||||||
]
|
]
|
||||||
|
|
||||||
if @options[:reload_paths]
|
if @options[:reload_paths]
|
||||||
@options[:reload_paths].split(',').each do |part|
|
@options[:reload_paths].split(',').each do |part|
|
||||||
match_against << %r{^#{part}}
|
match_against << %r{^#{part}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
paths.any? do |path|
|
paths.any? do |path|
|
||||||
match_against.any? do |matcher|
|
match_against.any? do |matcher|
|
||||||
path.match(matcher)
|
path.match(matcher)
|
||||||
|
|
Loading…
Add table
Reference in a new issue