Class: ScoutAgent::Assignment::Stop

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

Overview

Invoke with:

sudo scout_agent stop

This command halts the currently running agent. The agent is asked nicely to stop. If it doesn’t respond within a few seconds though, it is forced to terminate.

Constant Summary collapse

WAIT_COUNT =

The number of periods between stop checks after a process has been signaled. Checks will be made until it’s obvious the process obeyed the request or until this number of checks has been made.

10
WAIT_DELAY =

The pause in seconds between stop checks after a process has been signaled.

0.5

Instance Attribute Summary

Attributes inherited from ScoutAgent::Assignment

#group, #other_args, #switches, #user

Instance Method Summary collapse

Methods inherited from ScoutAgent::Assignment

choose_group, choose_user, #initialize, plan, #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

Runs the stop command.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/scout_agent/assignment/stop.rb', line 29

def execute
  @agent = IDCard.new(:lifeline)
  if @agent.pid_file.exist?
    signal_all("TERM")
    if Plan.pid_dir.entries.any? { |pid| pid.to_s =~ /\w+\.pid\z/ }
      puts "\nTERM signals were ignored, sending KILL signals.\n\n"
      signal_all("KILL")
      abort_with_failed_to_stop
    end
    puts "All processes stopped."
  else
    abort_with_not_running_notice
  end
end