Class: ScoutAgent::Assignment::Stop

Inherits:
ScoutAgent::Assignment show all
Defined in:
lib/scout_agent/assignment/stop.rb

Instance Attribute Summary

Attributes inherited from ScoutAgent::Assignment

#group, #other_args, #switches, #user

Instance Method Summary collapse

Methods inherited from ScoutAgent::Assignment

#initialize, #prepare_and_execute

Methods included from Tracked

#clear_status, #force_status_database_reload, #status, #status_database, #status_log

Constructor Details

This class inherits a constructor from ScoutAgent::Assignment

Instance Method Details

#executeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/scout_agent/assignment/stop.rb', line 7

def execute
  @agent = IDCard.new(:lifeline)
  if @agent.pid_file.exist?
    puts "Stopping #{ScoutAgent.proper_agent_name} (PID #{@agent.pid})..."
    signal_and_wait("TERM")
    if @agent.pid_file.exist?
      puts "TERM signal was ignored, sending KILL..."
      signal_and_wait("KILL")
      if @agent.pid_file.exist?
        abort_with_failed_to_stop
      end
    end
    puts "Stopped."
  else
    abort_with_not_running_notice
  end
end