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 ⇒ void
Simply stop, then start the server.
-
.shutdown ⇒ void
Stop the current instance, exit Webrick.
-
.start(opts = {}) ⇒ void
Start an instance of Middleman::Application.
-
.stop ⇒ void
Detach the current Middleman::Application instance.
Class Attribute Details
.app ⇒ Object (readonly)
Returns the value of attribute app.
9 10 11 |
# File 'lib/middleman-core/preview_server.rb', line 9 def app @app end |
.host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/middleman-core/preview_server.rb', line 9 def host @host end |
.port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/middleman-core/preview_server.rb', line 9 def port @port end |
Class Method Details
.reload ⇒ void
This method returns an undefined value.
Simply stop, then start the server
60 61 62 63 64 65 66 67 |
# File 'lib/middleman-core/preview_server.rb', line 60 def reload logger.info "== The Middleman is reloading" unmount_instance mount_instance logger.info "== The Middleman is standing watch at http://#{host}:#{port}" end |
.shutdown ⇒ void
This method returns an undefined value.
Stop the current instance, exit Webrick
71 72 73 74 |
# File 'lib/middleman-core/preview_server.rb', line 71 def shutdown stop @webrick.shutdown end |
.start(opts = {}) ⇒ void
This method returns an undefined value.
Start an instance of Middleman::Application
14 15 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 |
# File 'lib/middleman-core/preview_server.rb', line 14 def start(opts={}) @options = opts @host = @options[:host] || Socket.gethostname @port = @options[:port] || DEFAULT_PORT mount_instance logger.info "== The Middleman is standing watch at http://#{host}:#{port}" @initialized ||= false unless @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") @webrick.start # $mm_shutdown is set by the signal handler if $mm_shutdown shutdown exit end end end |
.stop ⇒ void
This method returns an undefined value.
Detach the current Middleman::Application instance
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/middleman-core/preview_server.rb', line 44 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 |