SSHKit::Runner::ExecuteError: Exception while executing as deploy@xxxxx

SSHKit::Runner::ExecuteError: Exception while executing as deploy@xxxxx

我正在尝试使用 NGINX 和 Capistrano 将我的 rails 应用程序部署到 AWS。 运行 部署命令:

$ cap production deploy

[41abe7d2] Running ~/.rvm/bin/rvm version as deploy@172.31.20.41
DEBUG [41abe7d2] Command: ~/.rvm/bin/rvm version
DEBUG [41abe7d2]    rvm 1.26.11 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [41abe7d2]
DEBUG [41abe7d2] Finished in 0.429 seconds with exit status 0 (successful).
rvm 1.26.11 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
DEBUG [61defd93] Running ~/.rvm/bin/rvm current as deploy@172.31.20.41
DEBUG [61defd93] Command: ~/.rvm/bin/rvm current
DEBUG [61defd93]    ruby-2.2.1
DEBUG [61defd93]
DEBUG [61defd93] Finished in 0.140 seconds with exit status 0 (successful).
ruby-2.2.1
DEBUG [01260e54] Running ~/.rvm/bin/rvm ruby 2.2.1p85 do ruby --version as deploy@172.31.20.41
DEBUG [01260e54] Command: ~/.rvm/bin/rvm ruby 2.2.1p85 do ruby --version
DEBUG [01260e54]    Please note that `rvm ruby ...` was removed, try `ruby 2.2.1p85 do ruby --version` or `rvm all do ruby 2.2.1p85 do ruby --version` instead. ( see: 'rvm usage' )
DEBUG [01260e54]
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@172.31.20.41: ruby exit status: 1
ruby stdout: Please note that `rvm ruby ...` was removed, try `ruby 2.2.1p85 do ruby --version` or `rvm all do ruby 2.2.1p85 do ruby --version` instead. ( see: 'rvm usage' )
ruby stderr: Nothing written

这是我的 capfile

# Load DSL and set up stages
require 'capistrano/setup'

# Include default deployment tasks
require 'capistrano/deploy'

require 'capistrano/bundler'
require 'capistrano/rvm'
require 'capistrano/rails/assets' # for asset handling add
require 'capistrano/rails/migrations' # for running migrations
require 'capistrano/puma'

# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

这是我的 deploy.rb

# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'Speyskraft_cms'
set :repo_url, 'https://onozor@bitbucket.org/onozor/speyskraft_cms.git' # Edit this to match your repository
set :branch, :master
set :deploy_to, '/home/deploy/speyskraft_cms'
set :scm_username, "deploy"
set :scm_passphrase, "onozorgheneho"
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 5
set :rvm_type, :user
set :rvm_ruby_version, 'ruby 2.2.1p85' # Edit this if you are using MRI Ruby

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"    #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'production'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

namespace :deploy do

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
      # within release_path do
      #   execute :rake, 'cache:clear'
      # end
    end
  end

end

请帮我解决这个问题这是我第一次在 AWS 上部署。提前致谢。

那是因为你的 :rvm_ruby_version 中的 space 导致生成类似弃用的 rvm 命令,尝试替换为:

set :rvm_ruby_version, 'ruby-2.2.1p85'

SSHKit::Runner::ExecuteError: 失败意味着 prod 服务器无法正确处理您的请求。尝试在您部署到的用户上安装 nodejsyarn。 Docker 通过从开发人员那里抽象出大部分生产配置来简化堆栈。

cap production deploy --trace

sudo apt-get install nodejs

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt update

sudo apt install yarn