Class: Middleman::Cli::Server

Inherits:
Thor
  • Object
show all
Defined in:
lib/middleman-core/cli/server.rb

Overview

Server thor task

Instance Method Summary collapse

Instance Method Details

#serverObject

Start the server



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/middleman-core/cli/server.rb', line 54

def server
  require 'middleman-core'
  require 'middleman-core/preview_server'

  unless 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'],
    latency: options['latency']
  }

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