Class: ElasticBeans::Command::Kill

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_beans/command/kill.rb

Overview

:nodoc: all

Constant Summary collapse

USAGE =
"kill COMMAND_ID"
DESC =
"Kill a running command or cancel a scheduled command that was enqueued with `exec`"
LONG_DESC =
"Kill a running command or cancel a scheduled command that was enqueued with `exec`.\nYou can find an enqueued command's ID by running `ps`.\n\nCommands are run in an \"exec\" environment, separate from your webserver or worker environments.\nWhen they are enqueued, metadata is created in S3 and removed when the command is complete.\nAdding a special piece of metadata cancels the command.\nThe command is sent a SIGTERM, and then a SIGKILL if it has not yet died.\n\nRequires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.\n"

Instance Method Summary collapse

Constructor Details

#initialize(application:, ui:) ⇒ Kill



22
23
24
25
# File 'lib/elastic_beans/command/kill.rb', line 22

def initialize(application:, ui:)
  @application = application
  @ui = ui
end

Instance Method Details

#run(command_id) ⇒ Object



27
28
29
30
31
# File 'lib/elastic_beans/command/kill.rb', line 27

def run(command_id)
  ui.info("Scheduling command '#{command_id}' on #{application.name} for termination...")
  application.kill_command(command_id)
  ui.info("It may be a few moments before the command terminates. If this is an interactive command, it will not be terminated.")
end