Class: Sunshine::RestartCommand

Inherits:
ListCommand show all
Defined in:
lib/commands/restart.rb

Overview

Runs the restart script of all specified sunshine apps.

Usage: sunshine restart [options] app_name [more names…]

Arguments:

app_name     Name of the application to restart.

Options:

-f, --format FORMAT        Set the output format (txt, yml, json)
-u, --user USER            User to use for remote login. Use with -r.
-r, --remote svr1,svr2     Run on one or more remote servers.
-S, --sudo                 Run remote commands using sudo or sudo -u USER
-v, --verbose              Run in verbose mode.

Instance Attribute Summary

Attributes inherited from ListCommand

#app_list, #shell

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ListCommand

build_response, #details, #each_app, exec_each_server, #exist?, #initialize, json_format, load_list, #response_for_each, save_list, #status, #status_after_command, txt_format, yml_format

Methods inherited from DefaultCommand

build_response, copy_middleware, copy_rakefile, opt_parser, parse_remote_args

Constructor Details

This class inherits a constructor from Sunshine::ListCommand

Class Method Details

.exec(names, config) ⇒ Object

Takes an array and a hash, runs the command and returns:

true: success
false: failed
exitcode:
  code == 0: success
  code != 0: failed

and optionally an accompanying message.



29
30
31
32
33
34
35
# File 'lib/commands/restart.rb', line 29

def self.exec names, config
  output = exec_each_server config do |shell|
    new(shell).restart(names)
  end

  return output
end

.parse_args(argv) ⇒ Object

Parses the argv passed to the command



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/commands/restart.rb', line 49

def self.parse_args argv
  parse_remote_args(argv) do |opt, options|
    opt.banner = <<-EOF

Usage: #{opt.program_name} restart [options] app_name [more names...]

Arguments:
app_name     Name of the application to restart.
    EOF

  end
end

Instance Method Details

#restart(app_names) ⇒ Object

Restart specified apps.



41
42
43
# File 'lib/commands/restart.rb', line 41

def restart app_names
  status_after_command :restart, app_names, :sudo => false
end