fixed usage of netssh options
This commit is contained in:
parent
b0a4edcf74
commit
ba3ed400fa
|
@ -1,34 +1,42 @@
|
|||
namespace :load do
|
||||
task :defaults do
|
||||
# add rails to rvm_map_bins
|
||||
rvm_map_bins = fetch(:rvm_map_bins) || []
|
||||
rvm_map_bins << :rails
|
||||
set(:rvm_map_bins, rvm_map_bins)
|
||||
set :rvm_map_bins, fetch(:rvm_map_bins, []).push(:rails)
|
||||
|
||||
# add which to map_bins
|
||||
set :rvm_map_bins, fetch(:rvm_map_bins, []).push(:which)
|
||||
set :rbenv_map_bins, fetch(:rbenv_map_bins, []).push(:which)
|
||||
|
||||
# add which to bundle_bins
|
||||
set :bundle_bins, fetch(:bundle_bins, []).push(:which)
|
||||
end
|
||||
end
|
||||
|
||||
namespace :rails do
|
||||
|
||||
desc "Interact with a remote rails console"
|
||||
task console: ['deploy:set_rails_env'] do
|
||||
on primary :app do |host|
|
||||
ssh_cmd_options = []
|
||||
within current_path do
|
||||
fail 'Rails binary not found!' unless test(:which, 'rails')
|
||||
end
|
||||
|
||||
ssh_cmd_options = []
|
||||
rails_console_args = []
|
||||
|
||||
if host.ssh_options && host.ssh_options[:proxy]
|
||||
template = host.ssh_options[:proxy].command_line_template
|
||||
ssh_cmd_options << "-o ProxyCommand=\"#{template}\""
|
||||
end
|
||||
|
||||
ssh_cmd_options_str = ssh_cmd_options.join(' ') if ssh_cmd_options.size > 0
|
||||
user_host = [host.user, host.hostname].compact.join('@')
|
||||
ssh_cmd = "ssh #{ssh_cmd_options_str} #{user_host} -p #{host.port || 22}"
|
||||
rails_console_args << '--sandbox' if ENV.key?('sandbox') || ENV.key?('s')
|
||||
|
||||
sandbox_arg = ENV.key?('sandbox') || ENV.key?('s') ? '-s' : ''
|
||||
cmd = SSHKit::Command.new(:rails, "console #{fetch(:rails_env)} #{sandbox_arg}", host: host)
|
||||
cmd = SSHKit::Command.new(:rails, "console #{fetch(:rails_env)} #{rails_console_args.join(' ')}", host: host)
|
||||
SSHKit.config.output << cmd
|
||||
|
||||
user_host = [host.user, host.hostname].compact.join('@')
|
||||
ssh_cmd = "ssh #{ssh_cmd_options.join(' ')} #{user_host} -p #{host.port || 22}"
|
||||
|
||||
exec(%Q(#{ssh_cmd} -t "cd #{current_path} && (#{cmd.environment_string} #{cmd})"))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue