Class: Bridgetown::Routines::Server
- Inherits:
-
Object
- Object
- Bridgetown::Routines::Server
- Defined in:
- bridgetown-core/lib/bridgetown-core/routines/server.rb
Instance Method Summary collapse
-
#execute(instance) ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#initialize(site:, port: nil, bind: nil) ⇒ Server
constructor
A new instance of Server.
-
#key ⇒ Object
-
#name ⇒ Object
Constructor Details
#initialize(site:, port: nil, bind: nil) ⇒ Server
Returns a new instance of Server.
6 7 8 9 10 |
# File 'bridgetown-core/lib/bridgetown-core/routines/server.rb', line 6 def initialize(site:, port: nil, bind: nil) @site = site @port = port @bind = bind end |
Instance Method Details
#execute(instance) ⇒ Object
rubocop:disable Metrics/AbcSize
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'bridgetown-core/lib/bridgetown-core/routines/server.rb', line 12 def execute(instance) # rubocop:disable Metrics/AbcSize Bridgetown.logger.set_prefix("Server", color: :yellow) server = Bridgetown::Rack::Server.new(port: @port, bind: @bind) Bridgetown.logger.info "" Bridgetown.logger.info "", "Starting Bridgetown server ...".white if server.respond_to?(:bind) && server.respond_to?(:port) uri = URI("#{server.bind}:#{server.port}") uri.scheme = uri.scheme.gsub("tcp", "http").gsub("ssl", "https") Bridgetown.logger.info "", "Serving at: ".white Bridgetown.logger.info "", uri.to_s.cyan Bridgetown.logger.info "", "#{uri.scheme}://#{external_ip}:#{server.port}" end Bridgetown.logger.info "" instance.exec("bundle", "exec", *server.command, ready: true) end |
#key ⇒ Object
35 |
# File 'bridgetown-core/lib/bridgetown-core/routines/server.rb', line 35 def key = :server |
#name ⇒ Object
34 |
# File 'bridgetown-core/lib/bridgetown-core/routines/server.rb', line 34 def name = "Bridgetown Server" |