Capistrano 3的部署由于某种原因而破裂

时间:2016-02-12 15:28:20

标签: ruby-on-rails rvm capistrano rvm1-capistrano3

好,

我遇到了一些奇怪的问题,我们的部署不再适用了。我无法跟踪所有变化的内容,但我希望有人可以帮助我调试此问题并找出问题所在。

deploy.rb

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

set :application, 'app_name'
set :repo_url, 'github_url'
set :deploy_to, '/home/user/path'

# Source Control Configuration
set :scm, :git
# Produces: Please enter the name of the branch. (develop):
set(:branch, ask('the name of the branch.', 'develop'))

# Ask whether we want to perform a backup.
# Produces: Please enter whether to perform a backup of the database? (Y):
set(:backup, ask('whether to perform a backup of the database?', 'Y'))

puts("setting branch to: #{fetch(:branch)}")

set :user, 'my_user'

set :assets_roles, [:web, :app, :vm]
set :keep_assets, 2

set :linked_files, fetch(:linked_files, []).push('.chamber.pem', 'Procfile', '.env')
set :linked_dirs, fetch(:linked_dirs, []).push('data', 'tmp', 'log', 'uploads')

set :keep_releases, 10

set :bundle_path, nil
set :bundle_binstubs, nil
set :bundle_flags, '--system'

set :rvm1_map_bins, fetch(:rvm1_map_bins, []).push('honeybadger')

# Slack integration options
set :slack_via_slackbot, Settings.slack.via_slackbot
set :slack_team, Settings.slack.team
set :slack_token, Settings.slack.token
set :slack_icon_emoji, -> { Settings.slack.icon_emoji }
set :slack_channel, -> { Settings.slack.channel }
set :slack_username, -> { Settings.slack.username }
set :slack_run_starting, -> { Settings.slack.run_starting }
set :slack_run_finished, -> { Settings.slack.run_finished }
set :slack_run_failed, -> { Settings.slack.run_failed }
set :slack_msg_finished, -> { "@channel #{ENV['USER'] || ENV['USERNAME']} has deployed branch *#{fetch :branch}* of #{fetch :application} to *#{fetch :rails_env}*." }
set :slack_msg_failed, -> { "#{ENV['USER'] || ENV['USERNAME']} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}." }

# Rake config
SSHKit.config.command_map[:rake] = 'bundle exec rake'

before 'deploy:started', 'deploy:rm:stop'
after 'deploy:rm:stop', 'deploy:rm:backup'
after 'deploy:finished', 'deploy:rm:start'
after 'deploy:migrate', 'deploy:rm:seed

Capfile

# Load DSL and set up stages
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'rvm1/capistrano3'  # Do not use capistrano/bundler
require 'whenever/capistrano'
require 'capistrano/honeybadger'
require 'slackistrano/capistrano'

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

require 'net/ssh/proxy/command'
def vm(tunnel:, tunnel_user: fetch(:user), vm_user: fetch(:user))
  server "#{fetch(:stage)}-vm01", {
    roles: [:vm],
    # The user on the VM
    user: vm_user,
    ssh_options: {
      # The user on the machine we're tunneling through
      proxy: Net::SSH::Proxy::Command.new("ssh #{tunnel_user}@#{tunnel} -W %h:%p"),
    }
  }
end

所以我可以在本地运行cap命令,它可以完成部分工作。首先使用新的链轮有一些问题,但现在它在需要预编译资产时抱怨以下内容:

INFO [21eca199] Running bundle exec rake assets:precompile as riskmethods@playground.riskmethods.net DEBUG [21eca199] Command: cd /home/riskmethods/riskmethods/releases/20160212152030 && ( export RAILS_ENV="playground" ; bundle exec rake assets:precompile ) 
DEBUG [2eac7a5b] Finished in 0.078 seconds with exit status 0 (successful). 
INFO [4b29f0c4] Running bundle exec rake assets:precompile as riskmethods@playground-vm01 
DEBUG [4b29f0c4] Command: cd /home/riskmethods/riskmethods/releases/20160212152030 && ( export RAILS_ENV="playground" ; bundle exec rake assets:precompile ) 
DEBUG [21eca199]        bash: bundle: command not found 
 (Backtrace restricted to imported tasks) 
 cap aborted! 
  SSHKit::Runner::ExecuteError: Exception while executing as riskmethods@playground.riskmethods.net: rake exit status: 127
  rake stdout: Nothing written 
  rake stderr: bash: bundle: command not found


  SSHKit::Command::Failed:
  rake exit status: 127 
  rake stdout: Nothing written 
  rake stderr: bash: bundle: command not found

  Tasks: TOP => deploy:assets:precompile
  (See full trace by running task with --trace)
  The deploy has failed with an error: 
    Exception while executing as riskmethods@playground.riskmethods.net: 
    rake exit status: 127 
    rake stdout: Nothing written 
    rake stderr: bash: bundle: command not found 

DEBUG [4b29f0c4]        bash: bundle: command not found

1 个答案:

答案 0 :(得分:0)

正如您的错误消息bash: bundle: command not found

您似乎没有在服务器上安装gem bundler

通过运行以下命令来在服务器上安装bundler gem

gem install bundler