Class: Nutella::Stop

Inherits:
RunCommand show all
Defined in:
lib/commands/stop.rb

Instance Method Summary collapse

Methods inherited from RunCommand

#compile_and_dependencies, #parse_cli_parameters, #parse_run_id_from, #print_success_message

Instance Method Details

#run(args = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/commands/stop.rb', line 8

def run(args=nil)

  # If the current directory is not a nutella application, return
  unless Nutella.current_app.exist?
    console.warn 'The current directory is not a nutella application'
    return
  end

  # Extract run (passed run name) and run_id
  run_id = parse_run_id_from args
  app_id = Nutella.current_app.config['name']

  # Check that the specified run exists in the list and, if it doesn't, return
  return unless remove_from_run_list app_id, run_id

  # Stops all run-level bots
  Tmux.kill_run_session app_id, run_id

  # Stop all app-level bots (if any, if needed)
  stop_app_bots app_id

  # Stop all framework-level components (if needed)
  if Nutella.runlist.empty?
    stop_framework_components
  end

  # If running on the internal broker, stop it if needed
  if Nutella.runlist.empty?
    stop_internal_broker
    stop_mongo
  end

  # Output success message
  print_success_message(app_id, run_id, 'stopped')
end