Module: Contrast::Service
Overview
A Rake task designed to allow control of the Contrast Service as a stand alone executable rather than one managed by the Agent running in a process forked from the application
Class Method Summary collapse
-
.start_service ⇒ Object
Start the service if it is not already running.
-
.stop_service ⇒ Object
Stop the service if it is running.
Methods included from Components::Interface
Class Method Details
.start_service ⇒ Object
Start the service if it is not already running
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/contrast/tasks/service.rb', line 18 def self.start_service puts 'Starting Contrast Service' service_log = CONTRAST_SERVICE.logger_path if File.writable?(service_log) spawn('contrast_service', out: File::NULL, err: service_log) else spawn('contrast_service', %i[out err] => File::NULL) end watcher = Contrast::Agent::Thread.new do sleep(0.05) until Contrast::Utils::OS.running? end watcher.join(1) puts Contrast::Utils::OS.running? ? 'Contrast Service started successfully.' : 'Contrast Service did not start.' end |
.stop_service ⇒ Object
Stop the service if it is running
35 36 37 38 |
# File 'lib/contrast/tasks/service.rb', line 35 def self.stop_service pid = `ps aux | grep contrast-servic[e] | awk '{print $2}'` `kill #{ pid }` if pid end |