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 =
<<-LONG_DESC
Kill a running command or cancel a scheduled command that was enqueued with `exec`.
You can find an enqueued command's ID by running `ps`.

Commands are run in an "exec" environment, separate from your webserver or worker environments.
When they are enqueued, metadata is created in S3 and removed when the command is complete.
Adding a special piece of metadata cancels the command.
The command is sent a SIGTERM, and then a SIGKILL if it has not yet died.

Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
LONG_DESC

Instance Method Summary collapse

Constructor Details

#initialize(application:, ui:) ⇒ Kill

Returns a new instance of 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