Class: Entrance::Agent::Config

Inherits:
OpenStruct
  • Object
show all
Extended by:
Globalizer
Defined in:
lib/entrance/agent/config.rb

Instance Attribute Summary

Attributes included from Globalizer

#current

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Config

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/entrance/agent/config.rb', line 14

def initialize params={}
  params[:path]               ||= "/doorkeepr/entrance"
  params[:api_headers]        ||= {
      "X-Doorkeepr-API"          => 1,
      "Accept"                   => 'application/json',
    }
  params[:api_path]           ||= "api"
  params[:api_timeout]        ||= 5
  params[:user_agent]         ||= "Doorkeepr Watcher 1"
  params[:doorkeepr_server]   ||= "http://localhost:3000"
  params[:doorkeepr_customer] ||= ENV["USER"]
  params[:doorkeepr_service]  ||= "rails"
  params[:doorkeepr_url]      ||= "/doorkeepr"
  params[:workdir]            ||= Pathname.new("/tmp")
  params[:id_file]            ||= params[:workdir].join("entrance.id").to_s
  params[:entrance]             = nil
  params[:id]                   = nil
  params[:customer]           ||= ENV["CUSTOMER"] || "global"
  params[:stats_user]         ||= "haproxy"
  params[:stats_pass]         ||= "secret"
  params[:http_port]          ||= 80
  params[:https_port]         ||= 443
  params[:health_url]         ||= "/health"
  super params
end

Instance Method Details

#api_urlObject



61
62
63
# File 'lib/entrance/agent/config.rb', line 61

def api_url
  doorkeepr_server.join(api_path)
end

#config_file_pathObject



45
46
47
# File 'lib/entrance/agent/config.rb', line 45

def config_file_path
  id_files_prefix + "cfg"
end

#doorkeepr_serverObject



54
55
56
57
58
59
60
# File 'lib/entrance/agent/config.rb', line 54

def doorkeepr_server
  Pathname.new begin
    Boutons.doorkeepr.to_s
  rescue Boutons::SynapseNotFound
    @table[:doorkeepr_server]
  end
end

#get_bindingObject



64
65
66
# File 'lib/entrance/agent/config.rb', line 64

def get_binding
  binding
end

#idObject



39
40
41
# File 'lib/entrance/agent/config.rb', line 39

def id
  entrance.id
end

#id_files_prefixObject



42
43
44
# File 'lib/entrance/agent/config.rb', line 42

def id_files_prefix
  workdir.join("entrance-#{id}").to_s + "."
end

#pid_file_pathObject



51
52
53
# File 'lib/entrance/agent/config.rb', line 51

def pid_file_path
  id_files_prefix + "pid"
end

#socket_file_pathObject



48
49
50
# File 'lib/entrance/agent/config.rb', line 48

def socket_file_path
  id_files_prefix + "sock"
end