Class: Scout::StreamerDaemon
- Inherits:
-
DaemonSpawn::Base
- Object
- DaemonSpawn::Base
- Scout::StreamerDaemon
- Defined in:
- lib/scout/streamer_daemon.rb
Instance Attribute Summary
Attributes inherited from DaemonSpawn::Base
#app_name, #index, #log_file, #pid_file, #signal, #singleton, #sync_log, #timeout, #working_dir
Class Method Summary collapse
-
.start_daemon(history_file, streamer_command, hostname, http_proxy) ⇒ Object
this is the public-facing method for starting the streaming daemon.
-
.stop_daemon(history_file) ⇒ Object
this is the public-facing method for stopping the streaming daemon.
Instance Method Summary collapse
-
#start(streamer_args) ⇒ Object
this method is called by DaemonSpawn’s class start method.
-
#stop ⇒ Object
this method is called by DaemonSpawn’s class stop method.
Methods inherited from DaemonSpawn::Base
#alive?, build, #classname, find, #initialize, #pid, restart, spawn!, start, status, stop
Constructor Details
This class inherits a constructor from DaemonSpawn::Base
Class Method Details
.start_daemon(history_file, streamer_command, hostname, http_proxy) ⇒ Object
this is the public-facing method for starting the streaming daemon
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scout/streamer_daemon.rb', line 5 def self.start_daemon(history_file, streamer_command, hostname, http_proxy) streamer_log_file=File.join(File.dirname(history_file),"scout_streamer.log") streamer_pid_file=File.join(File.dirname(history_file),"scout_streamer.pid") = {:log_file => streamer_log_file, :pid_file => streamer_pid_file, :sync_log => true, :working_dir => File.dirname(history_file)} # streamer command might look like: start,A0000000000123,a,b,c,1,3,cpu,memory tokens = streamer_command.split(",") tokens.shift # gets rid of the "start" streaming_key = tokens.shift p_app_id = tokens.shift p_key = tokens.shift p_secret = tokens.shift numerical_tokens = tokens.select { |token| token =~ /\A\d+\Z/ } system_metric_collectors = (tokens - numerical_tokens).map(&:to_sym) plugin_ids = numerical_tokens.map(&:to_i) # we use STDOUT for the logger because daemon_spawn directs STDOUT to a log file streamer_args = [history_file,streaming_key,p_app_id,p_key,p_secret,plugin_ids,system_metric_collectors,hostname,http_proxy,Logger.new(STDOUT)] if File.exists?(streamer_pid_file) Scout::StreamerDaemon.restart(, streamer_args) else Scout::StreamerDaemon.start(, streamer_args) end end |
.stop_daemon(history_file) ⇒ Object
this is the public-facing method for stopping the streaming daemon
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scout/streamer_daemon.rb', line 35 def self.stop_daemon(history_file) streamer_log_file=File.join(File.dirname(history_file),"scout_streamer.log") streamer_pid_file=File.join(File.dirname(history_file),"scout_streamer.pid") = {:log_file => streamer_log_file, :pid_file => streamer_pid_file, :sync_log => true, :working_dir => File.dirname(history_file)} Scout::StreamerDaemon.stop(, []) end |
Instance Method Details
#start(streamer_args) ⇒ Object
this method is called by DaemonSpawn’s class start method.
49 50 51 52 |
# File 'lib/scout/streamer_daemon.rb', line 49 def start(streamer_args) history,streaming_key,p_app_id,p_key,p_secret,plugin_ids,system_metric_collectors,hostname,http_proxy,log = streamer_args @scout = Scout::Streamer.new(history, streaming_key, p_app_id, p_key, p_secret, plugin_ids, system_metric_collectors, hostname, http_proxy, log) end |