Class: Rhino::Launcher
- Inherits:
-
Object
- Object
- Rhino::Launcher
- Defined in:
- lib/rhino/launcher.rb
Overview
Handles the bootstrapping of the application (setting up sockets, building via rack, etc).
Usage:
launcher = Rhino.Launcher.new(5000, '0.0.0.0', reuseaddr, 64, './config.ru')
launcher.run
Instance Attribute Summary collapse
-
#backlog ⇒ Object
Returns the value of attribute backlog.
-
#bind ⇒ Object
Returns the value of attribute bind.
-
#config ⇒ Object
Returns the value of attribute config.
-
#port ⇒ Object
Returns the value of attribute port.
-
#reuseaddr ⇒ Object
Returns the value of attribute reuseaddr.
Instance Method Summary collapse
-
#initialize(port, bind, reuseaddr, backlog, config) ⇒ Launcher
constructor
A new instance of Launcher.
- #run ⇒ Object
Constructor Details
#initialize(port, bind, reuseaddr, backlog, config) ⇒ Launcher
Returns a new instance of Launcher.
17 18 19 20 21 22 23 |
# File 'lib/rhino/launcher.rb', line 17 def initialize(port, bind, reuseaddr, backlog, config) self.port = port self.bind = bind self.reuseaddr = reuseaddr self.backlog = backlog self.config = config end |
Instance Attribute Details
#backlog ⇒ Object
Returns the value of attribute backlog.
13 14 15 |
# File 'lib/rhino/launcher.rb', line 13 def backlog @backlog end |
#bind ⇒ Object
Returns the value of attribute bind.
12 13 14 |
# File 'lib/rhino/launcher.rb', line 12 def bind @bind end |
#config ⇒ Object
Returns the value of attribute config.
14 15 16 |
# File 'lib/rhino/launcher.rb', line 14 def config @config end |
#port ⇒ Object
Returns the value of attribute port.
11 12 13 |
# File 'lib/rhino/launcher.rb', line 11 def port @port end |
#reuseaddr ⇒ Object
Returns the value of attribute reuseaddr.
15 16 17 |
# File 'lib/rhino/launcher.rb', line 15 def reuseaddr @reuseaddr end |
Instance Method Details
#run ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rhino/launcher.rb', line 25 def run Rhino.logger.log("Rhino") Rhino.logger.log("#{bind}:#{port}") begin socket = Socket.new(:INET, :STREAM) socket.setsockopt(:SOL_SOCKET, :SO_REUSEADDR, reuseaddr) socket.bind(Addrinfo.tcp(self.bind, self.port)) socket.listen(self.backlog) server = Rhino::Server.new(application, [socket]) server.run ensure socket.close end end |