Class: Failbot::Server
- Inherits:
-
Object
- Object
- Failbot::Server
- Defined in:
- lib/failbot/server.rb
Overview
Interface for starting the exception relay server. This class constructs a temporary config file for ernie and starts the erlang server process.
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#tmp ⇒ Object
readonly
Returns the value of attribute tmp.
Instance Method Summary collapse
- #config_file ⇒ Object
- #configure ⇒ Object
- #exec! ⇒ Object
- #handler_file ⇒ Object
-
#initialize(port = nil, tmpdir = nil) ⇒ Server
constructor
A new instance of Server.
- #pid_file ⇒ Object
- #workers ⇒ Object
- #write_config ⇒ Object
Constructor Details
#initialize(port = nil, tmpdir = nil) ⇒ Server
Returns a new instance of Server.
8 9 10 11 |
# File 'lib/failbot/server.rb', line 8 def initialize(port=nil, tmpdir=nil) @port = (port || 6666).to_i @tmp = tmpdir || Dir.tmpdir end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
13 14 15 |
# File 'lib/failbot/server.rb', line 13 def port @port end |
#tmp ⇒ Object (readonly)
Returns the value of attribute tmp.
14 15 16 |
# File 'lib/failbot/server.rb', line 14 def tmp @tmp end |
Instance Method Details
#config_file ⇒ Object
33 34 35 |
# File 'lib/failbot/server.rb', line 33 def config_file "#{@tmp}/ernie.failbot.#{Failbot.environment}.cfg" end |
#configure ⇒ Object
28 29 30 31 |
# File 'lib/failbot/server.rb', line 28 def configure write_config config_file end |
#exec! ⇒ Object
48 49 50 51 |
# File 'lib/failbot/server.rb', line 48 def exec! configure exec "ernie", "-p", port.to_s, "-P", pid_file, "-d", "-c", config_file end |
#handler_file ⇒ Object
20 21 22 |
# File 'lib/failbot/server.rb', line 20 def handler_file File.('../handler.rb', __FILE__) end |
#pid_file ⇒ Object
24 25 26 |
# File 'lib/failbot/server.rb', line 24 def pid_file "#{@tmp}/failbot.#{port}.pid" end |
#workers ⇒ Object
16 17 18 |
# File 'lib/failbot/server.rb', line 16 def workers Failbot.config['workers'] || 1 end |
#write_config ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/failbot/server.rb', line 37 def write_config File.open(config_file, 'wb') do |io| io.write((<<-ERLANG).gsub(/^ {10}/, '')) [{module, failbot}, {type, external}, {command, "ruby #{handler_file}"}, {count, #{workers}}]. ERLANG end end |