Class: Central::Cli::Apps::RestartCommand

Inherits:
Clamp::Command
  • Object
show all
Includes:
Common, Common
Defined in:
lib/central/cli/apps/restart_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

#app_json, #create_yml, #current_dir, #extend_env_vars, #extend_options, #extend_secrets, #load_services, #normalize_env_vars, #parse_services, #prefixed_name, #require_config_file, #service_exists?, #token, #valid_addons

Methods included from Services::ServicesHelper

#create_service, #delete_service, #deploy_service, #get_service, #int_to_filesize, #parse_image, #parse_links, #parse_log_opts, #parse_memory, #parse_ports, #parse_relative_time, #parse_secrets, #parse_service_id, #restart_service, #scale_service, #show_service, #start_service, #stop_service, #update_service, #wait_for_deploy_to_finish

Methods included from Common

#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename

Instance Attribute Details

#service_prefixObject (readonly)

Returns the value of attribute service_prefix.



13
14
15
# File 'lib/central/cli/apps/restart_command.rb', line 13

def service_prefix
  @service_prefix
end

#servicesObject (readonly)

Returns the value of attribute services.



13
14
15
# File 'lib/central/cli/apps/restart_command.rb', line 13

def services
  @services
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/central/cli/apps/restart_command.rb', line 15

def execute
  require_config_file(filename)

  @service_prefix = project_name || current_dir
  @services = load_services(filename, service_list, service_prefix)
  if services.size > 0
    restart_services(services)
  elsif !service_list.empty?
    puts "No such service: #{service_list.join(', ')}".colorize(:red)
  end
end

#restart_services(services) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/central/cli/apps/restart_command.rb', line 27

def restart_services(services)
  services.each do |service_name, _opts|
    if service_exists?(service_name)
      puts "restarting #{prefixed_name(service_name)}"
      restart_service(token, prefixed_name(service_name))
    else
      puts "No such service: #{service_name}".colorize(:red)
    end
  end
end