Module: Middleman::PreviewServer
- Defined in:
- lib/middleman-core/preview_server.rb
Defined Under Namespace
Classes: FilteredWebrickLog
Constant Summary collapse
- DEFAULT_PORT =
4567
Class Attribute Summary collapse
-
.app ⇒ Object
readonly
Returns the value of attribute app.
-
.host ⇒ Object
readonly
Returns the value of attribute host.
-
.port ⇒ Object
readonly
Returns the value of attribute port.
Class Method Summary collapse
-
.reload
Simply stop, then start the server.
-
.shutdown
Stop the current instance, exit Webrick.
-
.start(opts = {})
Start an instance of Middleman::Application.
-
.stop
Detach the current Middleman::Application instance.
Class Attribute Details
.app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'lib/middleman-core/preview_server.rb', line 11 def app @app end |
.host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/middleman-core/preview_server.rb', line 11 def host @host end |
.port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/middleman-core/preview_server.rb', line 11 def port @port end |
Class Method Details
.reload
This method returns an undefined value.
Simply stop, then start the server
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/middleman-core/preview_server.rb', line 67 def reload logger.info '== The Middleman is reloading' begin app = new_app rescue => e logger.error "Error reloading Middleman: #{e}\n#{e.backtrace.join("\n")}" logger.info '== The Middleman is still running the application from before the error' return end unmount_instance mount_instance(app) logger.info '== The Middleman has reloaded' end |
.shutdown
This method returns an undefined value.
Stop the current instance, exit Webrick
86 87 88 89 |
# File 'lib/middleman-core/preview_server.rb', line 86 def shutdown stop @webrick.shutdown end |
.start(opts = {})
This method returns an undefined value.
Start an instance of Middleman::Application
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/middleman-core/preview_server.rb', line 16 def start(opts={}) @options = opts @host = @options[:host] || '0.0.0.0' @port = @options[:port] || DEFAULT_PORT mount_instance(new_app) logger.info "== The Middleman is standing watch at http://#{host}:#{port}" logger.info "== Inspect your site configuration at http://#{host}:#{port}/__middleman/" @initialized ||= false return if @initialized @initialized = true register_signal_handlers # Save the last-used @options so it may be re-used when # reloading later on. ::Middleman::Profiling.report('server_start') loop do @webrick.start # $mm_shutdown is set by the signal handler if $mm_shutdown shutdown exit elsif $mm_reload $mm_reload = false reload end end end |
.stop
This method returns an undefined value.
Detach the current Middleman::Application instance
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/middleman-core/preview_server.rb', line 51 def stop begin logger.info '== The Middleman is shutting down' rescue # if the user closed their terminal STDOUT/STDERR won't exist end if @listener @listener.stop @listener = nil end unmount_instance end |