lib/geordi/remote.rb in geordi-3.1.0 vs lib/geordi/remote.rb in geordi-3.2.0
- old
+ new
@@ -32,11 +32,10 @@
def dump(options = {})
# Generate dump on the server
shell options.merge({
remote_command: "dumple #{@config.env} --for_download",
- select_server: nil, # Dump must be generated on the primary server
})
destination_directory = File.join(@config.root, 'tmp')
FileUtils.mkdir_p destination_directory
destination_path = File.join(destination_directory, "#{@stage}.dump")
@@ -54,10 +53,23 @@
def console(options = {})
shell(options.merge(remote_command: Util.console_command(@config.env)))
end
def shell(options = {})
- server = options[:select_server] ? select_server : @config.primary_server
+ server_option = options[:select_server]
+ server_number = server_option.to_i
+
+ server = if server_option == 'select_server'
+ select_server
+ elsif server_number != 0 && server_number <= @config.servers.count
+ server_index = server_number - 1
+ @config.servers[server_index]
+ elsif server_option.nil?
+ @config.primary_server
+ else
+ Interaction.warn "Invalid server number: #{server_option}"
+ select_server
+ end
remote_command = "cd #{@config.remote_root} && #{@config.shell}"
remote_command << " -c '#{options[:remote_command]}'" if options[:remote_command]
Interaction.note 'Connecting to ' + server.to_s