Class: ZooMQ::Server
- Inherits:
-
Object
- Object
- ZooMQ::Server
- Extended by:
- Forwardable
- Defined in:
- lib/zoomq/server.rb,
lib/zoomq/server/worker.rb,
lib/zoomq/server/connection.rb
Defined Under Namespace
Classes: Connection, Worker
Instance Attribute Summary collapse
-
#fqdn ⇒ Object
readonly
Returns the value of attribute fqdn.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/zoomq/server.rb', line 18 def initialize $log.info("#{service_name}:initialize #{RUBY_DESCRIPTION}") $log.info("#{service_name}:initialize", { env: Env.mode, }) ZMachine.logger = $log Signal.register_shutdown_handler { shutdown } @fqdn = ::Socket.gethostbyname(::Socket.gethostname).first @zk = Zookeeper.new(service_name) end |
Instance Attribute Details
#fqdn ⇒ Object (readonly)
Returns the value of attribute fqdn.
16 17 18 |
# File 'lib/zoomq/server.rb', line 16 def fqdn @fqdn end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/zoomq/server.rb', line 16 def port @port end |
Instance Method Details
#run ⇒ Object
30 31 32 33 34 |
# File 'lib/zoomq/server.rb', line 30 def run # TODO: make it multi-threaded $log.info("#{service_name}:run", workers: 1) Worker.new(self).run end |
#shutdown ⇒ Object
36 37 38 39 |
# File 'lib/zoomq/server.rb', line 36 def shutdown @zk.close if @zk ZMachine.stop_event_loop end |