2016-02-12 73 views
1

好吧,Capistrano 3部署由於某種原因而中斷

我遇到了一個奇怪的問題,我們的部署不再工作了。我無法追蹤所有變化,但我希望有人能幫助我調試這個問題,並找出發生了什麼問題。

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 [email protected] 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 [email protected] 
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 [email protected]: 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 [email protected]: 
    rake exit status: 127 
    rake stdout: Nothing written 
    rake stderr: bash: bundle: command not found 

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

這是一個新的服務器還是現有的服務器? –

+0

現有服務器。問題大約在1周前開始 –

+0

它也在這裏發生,我無法使用捆綁器和資產編譯與capistrano –

回答

0

由於您的錯誤消息說bash: bundle: command not found

它好像你沒有創業板安裝bundler在服務器上

通過運行下面的命令應該做的伎倆在服務器上安裝捆綁寶石

gem install bundler

+0

bundler安裝在服務器上。通過SSH進入盒子並手動運行命令可以很好地工作。 –