Try to fix preview server config
This commit is contained in:
parent
aab7bac8a6
commit
8425692b86
|
@ -271,6 +271,8 @@ module Middleman
|
|||
# Before config is parsed, before extensions get to it.
|
||||
execute_callbacks(:initialized)
|
||||
|
||||
apply_cli_options
|
||||
|
||||
# Before config is parsed. Mostly used for extensions.
|
||||
execute_callbacks(:before_configuration)
|
||||
|
||||
|
@ -283,14 +285,7 @@ module Middleman
|
|||
# Run any `configure` blocks for the current mode.
|
||||
execute_callbacks([:configure, config[:mode]])
|
||||
|
||||
config[:cli_options].each do |k, v|
|
||||
setting = config.setting(k.to_sym)
|
||||
next unless setting
|
||||
|
||||
v = setting.options[:import].call(v) if setting.options[:import]
|
||||
|
||||
config[k.to_sym] = v
|
||||
end
|
||||
apply_cli_options
|
||||
|
||||
# Post parsing, pre-extension callback
|
||||
execute_callbacks(:after_configuration_eval)
|
||||
|
@ -308,6 +303,17 @@ module Middleman
|
|||
execute_callbacks(:ready) unless config[:exit_before_ready]
|
||||
end
|
||||
|
||||
def apply_cli_options
|
||||
config[:cli_options].each do |k, v|
|
||||
setting = config.setting(k.to_sym)
|
||||
next unless setting
|
||||
|
||||
v = setting.options[:import].call(v) if setting.options[:import]
|
||||
|
||||
config[k.to_sym] = v
|
||||
end
|
||||
end
|
||||
|
||||
# Eval config
|
||||
def evaluate_configuration!
|
||||
# Check for and evaluate local configuration in `config.rb`
|
||||
|
|
|
@ -172,18 +172,23 @@ module Middleman
|
|||
end
|
||||
|
||||
# store configured port to make a check later on possible
|
||||
configured_port = app.config[:port]
|
||||
configured_port = possible_from_cli(:port, app.config)
|
||||
|
||||
# Use configuration values to set `bind_address` etc. in
|
||||
# `server_information`
|
||||
server_information.use app.config
|
||||
server_information.use({
|
||||
bind_address: possible_from_cli(:bind_address, app.config),
|
||||
port: possible_from_cli(:port, app.config),
|
||||
server_name: possible_from_cli(:server_name, app.config),
|
||||
https: possible_from_cli(:https, app.config)
|
||||
})
|
||||
|
||||
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless app.config[:port] == configured_port
|
||||
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless server_information.port == configured_port
|
||||
|
||||
@environment = app.config[:environment]
|
||||
@environment = possible_from_cli(:environment, app.config)
|
||||
|
||||
@ssl_certificate = app.config[:ssl_certificate]
|
||||
@ssl_private_key = app.config[:ssl_private_key]
|
||||
@ssl_certificate = possible_from_cli(:ssl_certificate, app.config)
|
||||
@ssl_private_key = possible_from_cli(:ssl_private_key, app.config)
|
||||
|
||||
app.files.on_change :reload do
|
||||
$mm_reload = true
|
||||
|
@ -199,6 +204,14 @@ module Middleman
|
|||
app
|
||||
end
|
||||
|
||||
def possible_from_cli(key, config)
|
||||
if @cli_options[key] && @cli_options[key] != :undefined
|
||||
@cli_options[key]
|
||||
else
|
||||
config[key]
|
||||
end
|
||||
end
|
||||
|
||||
# Trap some interupt signals and shut down smoothly
|
||||
# @return [void]
|
||||
def register_signal_handlers
|
||||
|
|
Loading…
Reference in a new issue