Class: Waves::Servers::Base
Overview
Inherit from this class and define the #call method to create Servers. Like Rack Handlers, except with an attempt at a more generic interface. The #call method should yield with the actual server object.
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(application, host, port) ⇒ Base
constructor
A new instance of Base.
-
#start ⇒ Object
starts server, retrying every second until it succeeds.
- #stop ⇒ Object
Constructor Details
#initialize(application, host, port) ⇒ Base
Returns a new instance of Base.
12 13 14 15 |
# File 'lib/waves/servers/base.rb', line 12 def initialize( application, host, port ) @application = application @host = host ;@port = port end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
11 12 13 |
# File 'lib/waves/servers/base.rb', line 11 def application @application end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/waves/servers/base.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/waves/servers/base.rb', line 11 def port @port end |
Instance Method Details
#start ⇒ Object
starts server, retrying every second until it succeeds
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/waves/servers/base.rb', line 18 def start Thread.new do connect = false until connect do begin call do |server| @server = server Waves::Logger.info "#{self.class.basename} started on #{host}:#{port}." end rescue RuntimeError => e Waves::Logger.error e.to_s sleep 1 end connect = true end end end |