Don't accidentally start a new file listener every time the server reloads
This commit is contained in:
parent
e766e753e8
commit
2b2759fb77
|
@ -13,8 +13,6 @@ module Middleman
|
||||||
def start(options={})
|
def start(options={})
|
||||||
require "webrick"
|
require "webrick"
|
||||||
|
|
||||||
@first_run ||= true
|
|
||||||
|
|
||||||
app = ::Middleman::Application.server.inst do
|
app = ::Middleman::Application.server.inst do
|
||||||
if options[:environment]
|
if options[:environment]
|
||||||
set :environment, options[:environment]
|
set :environment, options[:environment]
|
||||||
|
@ -26,8 +24,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "== The Middleman is standing watch on port #{options[:port]||4567}"
|
puts "== The Middleman is standing watch on port #{options[:port]||4567}"
|
||||||
|
|
||||||
@webrick_is_running ||= false
|
|
||||||
@webrick ||= setup_webrick(
|
@webrick ||= setup_webrick(
|
||||||
options[:host] || "0.0.0.0",
|
options[:host] || "0.0.0.0",
|
||||||
options[:port] || DEFAULT_PORT,
|
options[:port] || DEFAULT_PORT,
|
||||||
|
@ -36,8 +33,9 @@ module Middleman
|
||||||
|
|
||||||
mount_instance(app)
|
mount_instance(app)
|
||||||
|
|
||||||
if @first_run
|
@initialized ||= false
|
||||||
@first_run = false
|
unless @initialized
|
||||||
|
@initialized = true
|
||||||
|
|
||||||
register_signal_handlers unless ::Middleman::WINDOWS
|
register_signal_handlers unless ::Middleman::WINDOWS
|
||||||
|
|
||||||
|
@ -71,8 +69,6 @@ module Middleman
|
||||||
private
|
private
|
||||||
|
|
||||||
def start_file_watcher
|
def start_file_watcher
|
||||||
preview_server = self
|
|
||||||
|
|
||||||
# Watcher Library
|
# Watcher Library
|
||||||
require "listen"
|
require "listen"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue