Class: Sunshine::StartCommand
- Inherits:
-
ListCommand
- Object
- DefaultCommand
- ListCommand
- Sunshine::StartCommand
- Defined in:
- lib/commands/start.rb
Overview
Runs the start script of all specified sunshine apps.
Usage: sunshine start [options] app_name [more names…]
Arguments:
app_name Name of the application to start.
Options:
-F, --force Stop apps that are running, then start them.
-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
Class Method Summary collapse
-
.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.
-
.parse_args(argv) ⇒ Object
Parses the argv passed to the command.
Instance Method Summary collapse
-
#start(app_names, force = false) ⇒ Object
Start specified apps.
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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/commands/start.rb', line 30 def self.exec names, config force = config['force'] output = exec_each_server config do |shell| new(shell).start(names, force) end return output end |
.parse_args(argv) ⇒ Object
Parses the argv passed to the command
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/commands/start.rb', line 55 def self.parse_args argv parse_remote_args(argv) do |opt, | opt. = <<-EOF Usage: #{opt.program_name} start [options] app_name [more names...] Arguments: app_name Name of the application to start. EOF opt.on('-F', '--force', 'Stop apps that are running before starting them again.') do ['force'] = true end end end |
Instance Method Details
#start(app_names, force = false) ⇒ Object
Start specified apps.
44 45 46 47 48 49 |
# File 'lib/commands/start.rb', line 44 def start app_names, force=false status_after_command :start, app_names, :sudo => false do |server_app| server_app.stop if server_app.running? && force end end |