Class: Webbynode::Commands::Restart

Inherits:
Webbynode::Command show all
Defined in:
lib/webbynode/commands/restart.rb

Constant Summary

Constants inherited from Webbynode::Command

Webbynode::Command::Aliases, Webbynode::Command::CommandError, Webbynode::Command::InvalidCommand, Webbynode::Command::InvalidOption, Webbynode::Command::Settings

Instance Method Summary collapse

Methods inherited from Webbynode::Command

add_alias, #api, class_for, command, command_class_name, description, for, #gemfile, #git, help, inherited, #initialize, #io, #no?, #notify, option, #option, #options, options_help, #param, #param_values, parameter, #params, #params_hash, params_help, #pushand, #remote_executor, requires_initialization!, requires_options!, requires_pushed_application!, #run, #server, setting, #settings, summary, summary_help, usage, #validate_initialization, #validate_options, #yes?

Constructor Details

This class inherits a constructor from Webbynode::Command

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/webbynode/commands/restart.rb', line 8

def execute
  exit if no?("Are you sure you wish to restart your webby? (y/n)")
  
  api.webbies.each do |webby|    
    if webby[1][:ip].eql?(git.parse_remote_ip)
      if webby[1][:status].eql?("on")
        puts "#{webby[0]} will now be rebooted!"
        api.post("/webby/#{webby[1][:name]}/reboot")
      else
        puts "#{webby[0]} is starting up!"
        api.post("/webby/#{webby[1][:name]}/start")
      end
    end
  end
end