Class: Nonnative::Server
Overview
Runtime runner that manages an in-process Ruby server.
A server runner:
-
starts the configured proxy (if any),
-
starts a Ruby thread that runs #perform_start,
-
waits briefly (via the runner
wait), and -
participates in readiness/shutdown via TCP port checks orchestrated by Pool.
Concrete server implementations are expected to subclass Server and implement:
-
#perform_start (to bind/listen and begin serving), and
-
#perform_stop (to gracefully shut down).
The underlying configuration is a ConfigurationServer.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Runner
Instance Method Summary collapse
-
#initialize(service) ⇒ Server
constructor
A new instance of Server.
-
#start ⇒ Array<(Integer, TrueClass)>
Starts the proxy (if any) and starts the server thread if not already started.
-
#stop ⇒ Integer
Stops the server if it is running.
Methods inherited from Runner
Constructor Details
Instance Method Details
#start ⇒ Array<(Integer, TrueClass)>
Starts the proxy (if any) and starts the server thread if not already started.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nonnative/server.rb', line 34 def start unless thread proxy.start @thread = Thread.new { perform_start } wait_start Nonnative.logger.info "started server '#{service.name}'" end [object_id, true] end |
#stop ⇒ Integer
Stops the server if it is running.
Calls #perform_stop, terminates the server thread, stops the proxy (if any), and waits briefly.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/nonnative/server.rb', line 52 def stop if thread perform_stop thread.terminate proxy.stop @thread = nil wait_stop Nonnative.logger.info "stopped server '#{service.name}'" end object_id end |