class Middleman::Cli::Server

Server thor task

Public Instance Methods

server() click to toggle source

Start the server

# File lib/middleman-core/cli/server.rb, line 50
def server
  require "middleman-core"
  require "middleman-core/preview_server"

  if !ENV["MM_ROOT"]
    puts "== Could not find a Middleman project config.rb"
    puts "== Treating directory as a static site to be served"
    ENV["MM_ROOT"] = Dir.pwd
    ENV["MM_SOURCE"] = ""
  end

  params = {
    :port              => options["port"],
    :host              => options["host"],
    :environment       => options["environment"],
    :debug             => options["verbose"],
    :instrumenting     => options["instrument"],
    :disable_watcher   => options["disable_watcher"],
    :reload_paths      => options["reload_paths"],
    :force_polling     => options["force_polling"]
  }

  puts "== The Middleman is loading"
  ::Middleman::PreviewServer.start(params)
end