Class: Harbor::HostAgent::Server
- Inherits:
-
Object
- Object
- Harbor::HostAgent::Server
- Defined in:
- lib/harbor/host_agent.rb
Instance Attribute Summary collapse
-
#bind ⇒ Object
readonly
Returns the value of attribute bind.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(config:, bearer_token:, bind: DEFAULT_BIND, port: DEFAULT_PORT, logger: nil) ⇒ Server
constructor
A new instance of Server.
- #run ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(config:, bearer_token:, bind: DEFAULT_BIND, port: DEFAULT_PORT, logger: nil) ⇒ Server
Returns a new instance of Server.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/harbor/host_agent.rb', line 36 def initialize(config:, bearer_token:, bind: DEFAULT_BIND, port: DEFAULT_PORT, logger: nil) raise ArgumentError, "bearer_token is required" if bearer_token.nil? || bearer_token.empty? @config = config @bearer_token = bearer_token @bind = bind @port = port @logger = logger || WEBrick::Log.new($stderr, WEBrick::Log::INFO) @tools = Harbor::Tools.new(config) end |
Instance Attribute Details
#bind ⇒ Object (readonly)
Returns the value of attribute bind.
34 35 36 |
# File 'lib/harbor/host_agent.rb', line 34 def bind @bind end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
34 35 36 |
# File 'lib/harbor/host_agent.rb', line 34 def port @port end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/harbor/host_agent.rb', line 47 def run @webrick = WEBrick::HTTPServer.new( BindAddress: @bind, Port: @port, Logger: @logger, AccessLog: [] ) mount_routes trap_signals @webrick.start end |
#stop ⇒ Object
59 60 61 |
# File 'lib/harbor/host_agent.rb', line 59 def stop @webrick&.shutdown end |