Capistrano部署后未编译Rails资产 [英] Rails assets aren't compiling after Capistrano deployment

查看:67
本文介绍了Capistrano部署后未编译Rails资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Capistrano部署我的Rails应用程序,除非我将ssh放入服务器并手动运行RAILS_ENV=development bundle exec rake assets:precompile,否则似乎不会对资产进行编译.

I'm deploying my Rails app using Capistrano and it seems that the assets aren't being compiled unless I ssh into the server and run RAILS_ENV=development bundle exec rake assets:precompile manually.

我已经尝试按照 capistrano/rails github页面上的说明进行操作,但我不是确定我是否错过了什么.

I've tried following the instructions on the capistrano/rails github page, but I'm not sure if I've missed something.

运行cap production deploy成功完成.但是我不知道如何检查assets:precompile任务是否真正运行.运行cap production deploy:assets:precompile也可以成功完成,但是服务器上没有明显变化.

Running cap production deploy completes successfully. But I don't know how to check whether the assets:precompile task was actually run. Running cap production deploy:assets:precompile also completes successfully, but with no apparent change on the server.

版本

Server version: Apache/2.4.7 (Ubuntu)
Phusion Passenger 5.0.22
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
Rails 4.2.5

capistrano (3.1.0)
capistrano-bundler (1.1.4)
capistrano-rails (1.1.6)
capistrano-rbenv (2.0.4)

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'

require 'capistrano/rbenv'
require 'capistrano/rails/assets'

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

config/deploy.rb

set :application, "website"
set :repo_url, "git@bitbucket.org:company/website.git"
set :deploy_to, "/var/www/#{fetch(:application)}"
set :user, "webmaster"

set :rbenv_path, '/home/webmaster/.rbenv'
set :rbenv_ruby, '2.2.3'

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

set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')

config/deploy/production.rb

set :stage, :production

server 'company.com', user: 'webmaster', roles: %{web app db}

为什么不编译资产?

[更新]

部署的输出

/home/alistair/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/capistrano-3.1.0/lib/capistrano/i18n.rb:4: warning: duplicated key at line 6 ignored: :starting
DEBUG [1f337009] Running /usr/bin/env [ -d /home/webmaster/.rbenv/versions/2.2.3 ] as webmaster@company.com
DEBUG [1f337009] Command: [ -d /home/webmaster/.rbenv/versions/2.2.3 ]
DEBUG [1f337009] Finished in 1.359 seconds with exit status 0 (successful).
INFO [90810a3d] Running /usr/bin/env mkdir -p /tmp/website/ as webmaster@company.com
DEBUG [90810a3d] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -p /tmp/website/ )
INFO [90810a3d] Finished in 0.098 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/website/git-ssh.sh 0.0%
INFO Uploading /tmp/website/git-ssh.sh 100.0%
INFO [056c0cd0] Running /usr/bin/env chmod +x /tmp/website/git-ssh.sh as webmaster@company.com
DEBUG [056c0cd0] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env chmod +x /tmp/website/git-ssh.sh )
INFO [056c0cd0] Finished in 0.095 seconds with exit status 0 (successful).
DEBUG [bc777b81] Running /usr/bin/env git ls-remote git@bitbucket.org:company/website.git as webmaster@company.com
DEBUG [bc777b81] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/website/git-ssh.sh" ; /usr/bin/env git ls-remote git@bitbucket.org:company/website.git )
DEBUG [bc777b81]  41758f51b425b0c7a57124dfeb623a1c16793f40  HEAD
41758f51b425b0c7a57124dfeb623a1c16793f40  refs/heads/master
DEBUG [bc777b81] Finished in 3.636 seconds with exit status 0 (successful).
INFO [b47c738d] Running /usr/bin/env mkdir -pv /var/www/website/shared /var/www/website/releases as webmaster@company.com
DEBUG [b47c738d] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -pv /var/www/website/shared /var/www/website/releases )
INFO [b47c738d] Finished in 0.095 seconds with exit status 0 (successful).
INFO [5e356ddf] Running /usr/bin/env mkdir -pv /var/www/website/shared/log /var/www/website/shared/tmp/pids /var/www/website/shared/tmp/cache /var/www/website/shared/tmp/sockets /var/www/website/shared/vendor/bundle /var/www/website/shared/public/system /var/www/website/shared/public/uploads /var/www/website/shared/public/assets as webmaster@company.com
DEBUG [5e356ddf] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -pv /var/www/website/shared/log /var/www/website/shared/tmp/pids /var/www/website/shared/tmp/cache /var/www/website/shared/tmp/sockets /var/www/website/shared/vendor/bundle /var/www/website/shared/public/system /var/www/website/shared/public/uploads /var/www/website/shared/public/assets )
INFO [5e356ddf] Finished in 0.099 seconds with exit status 0 (successful).
INFO [ea415b4a] Running /usr/bin/env mkdir -pv /var/www/website/shared/config /var/www/website/shared/config as webmaster@company.com
DEBUG [ea415b4a] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -pv /var/www/website/shared/config /var/www/website/shared/config )
INFO [ea415b4a] Finished in 0.098 seconds with exit status 0 (successful).
DEBUG [6e429c96] Running /usr/bin/env [ -f /var/www/website/shared/config/database.yml ] as webmaster@company.com
DEBUG [6e429c96] Command: [ -f /var/www/website/shared/config/database.yml ]
DEBUG [6e429c96] Finished in 0.097 seconds with exit status 0 (successful).
DEBUG [12f009aa] Running /usr/bin/env [ -f /var/www/website/shared/config/secrets.yml ] as webmaster@company.com
DEBUG [12f009aa] Command: [ -f /var/www/website/shared/config/secrets.yml ]
DEBUG [12f009aa] Finished in 0.101 seconds with exit status 0 (successful).
DEBUG [037f2152] Running /usr/bin/env [ -f /var/www/website/repo/HEAD ] as webmaster@company.com
DEBUG [037f2152] Command: [ -f /var/www/website/repo/HEAD ]
DEBUG [037f2152] Finished in 0.098 seconds with exit status 0 (successful).
INFO The repository mirror is at /var/www/website/repo
DEBUG [8761724b] Running /usr/bin/env if test ! -d /var/www/website/repo; then echo "Directory does not exist '/var/www/website/repo'" 1>&2; false; fi as webmaster@company.com
DEBUG [8761724b] Command: if test ! -d /var/www/website/repo; then echo "Directory does not exist '/var/www/website/repo'" 1>&2; false; fi
DEBUG [8761724b] Finished in 0.097 seconds with exit status 0 (successful).
DEBUG [a9f39ba9] Running /usr/bin/env cd /var/www/website/repo && git rev-parse --short HEAD as webmaster@company.com
DEBUG [a9f39ba9] Command: cd /var/www/website/repo && git rev-parse --short HEAD
DEBUG [a9f39ba9]  41758f5
DEBUG [a9f39ba9] Finished in 0.100 seconds with exit status 0 (successful).
INFO [8a7bf4c0] Running /usr/bin/env git remote update as webmaster@company.com
DEBUG [8a7bf4c0] Command: cd /var/www/website/repo && ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env git remote update )
DEBUG [8a7bf4c0]  Fetching origin
INFO [8a7bf4c0] Finished in 4.692 seconds with exit status 0 (successful).
DEBUG [894b0375] Running /usr/bin/env cd /var/www/website/repo && git rev-parse --short HEAD as webmaster@company.com
DEBUG [894b0375] Command: cd /var/www/website/repo && git rev-parse --short HEAD
DEBUG [894b0375]  41758f5
DEBUG [894b0375] Finished in 0.101 seconds with exit status 0 (successful).
DEBUG [78f3e509] Running /usr/bin/env if test ! -d /var/www/website/repo; then echo "Directory does not exist '/var/www/website/repo'" 1>&2; false; fi as webmaster@company.com
DEBUG [78f3e509] Command: if test ! -d /var/www/website/repo; then echo "Directory does not exist '/var/www/website/repo'" 1>&2; false; fi
DEBUG [78f3e509] Finished in 0.095 seconds with exit status 0 (successful).
INFO [8a07a0a1] Running /usr/bin/env mkdir -p /var/www/website/releases/20160301105814 as webmaster@company.com
DEBUG [8a07a0a1] Command: cd /var/www/website/repo && ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/website/git-ssh.sh" ; /usr/bin/env mkdir -p /var/www/website/releases/20160301105814 )
INFO [8a07a0a1] Finished in 0.095 seconds with exit status 0 (successful).
INFO [344742a3] Running /usr/bin/env git archive master | tar -x -C /var/www/website/releases/20160301105814 as webmaster@company.com
DEBUG [344742a3] Command: cd /var/www/website/repo && ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/website/git-ssh.sh" ; /usr/bin/env git archive master | tar -x -C /var/www/website/releases/20160301105814 )
INFO [344742a3] Finished in 0.102 seconds with exit status 0 (successful).
INFO [6018eedd] Running /usr/bin/env mkdir -pv /var/www/website/releases/20160301105814/config /var/www/website/releases/20160301105814/config as webmaster@company.com
DEBUG [6018eedd] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -pv /var/www/website/releases/20160301105814/config /var/www/website/releases/20160301105814/config )
INFO [6018eedd] Finished in 0.090 seconds with exit status 0 (successful).
DEBUG [ae6b6fb8] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/config/database.yml ] as webmaster@company.com
DEBUG [ae6b6fb8] Command: [ -L /var/www/website/releases/20160301105814/config/database.yml ]
DEBUG [ae6b6fb8] Finished in 0.088 seconds with exit status 1 (failed).
DEBUG [f9d7b6d6] Running /usr/bin/env [ -f /var/www/website/releases/20160301105814/config/database.yml ] as webmaster@company.com
DEBUG [f9d7b6d6] Command: [ -f /var/www/website/releases/20160301105814/config/database.yml ]
DEBUG [f9d7b6d6] Finished in 0.088 seconds with exit status 1 (failed).
INFO [07890c6f] Running /usr/bin/env ln -s /var/www/website/shared/config/database.yml /var/www/website/releases/20160301105814/config/database.yml as webmaster@company.com
DEBUG [07890c6f] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/config/database.yml /var/www/website/releases/20160301105814/config/database.yml )
INFO [07890c6f] Finished in 0.095 seconds with exit status 0 (successful).
DEBUG [4740cfae] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/config/secrets.yml ] as webmaster@company.com
DEBUG [4740cfae] Command: [ -L /var/www/website/releases/20160301105814/config/secrets.yml ]
DEBUG [4740cfae] Finished in 0.100 seconds with exit status 1 (failed).
DEBUG [6de85d60] Running /usr/bin/env [ -f /var/www/website/releases/20160301105814/config/secrets.yml ] as webmaster@company.com
DEBUG [6de85d60] Command: [ -f /var/www/website/releases/20160301105814/config/secrets.yml ]
DEBUG [6de85d60] Finished in 0.092 seconds with exit status 1 (failed).
INFO [1fceb704] Running /usr/bin/env ln -s /var/www/website/shared/config/secrets.yml /var/www/website/releases/20160301105814/config/secrets.yml as webmaster@company.com
DEBUG [1fceb704] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/config/secrets.yml /var/www/website/releases/20160301105814/config/secrets.yml )
INFO [1fceb704] Finished in 0.092 seconds with exit status 0 (successful).
INFO [8184d994] Running /usr/bin/env mkdir -pv /var/www/website/releases/20160301105814 /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/vendor /var/www/website/releases/20160301105814/public /var/www/website/releases/20160301105814/public /var/www/website/releases/20160301105814/public as webmaster@company.com
DEBUG [8184d994] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env mkdir -pv /var/www/website/releases/20160301105814 /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/tmp /var/www/website/releases/20160301105814/vendor /var/www/website/releases/20160301105814/public /var/www/website/releases/20160301105814/public /var/www/website/releases/20160301105814/public )
DEBUG [8184d994]  mkdir: created directory ‘/var/www/website/releases/20160301105814/tmp’
INFO [8184d994] Finished in 0.090 seconds with exit status 0 (successful).
DEBUG [b723a723] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/log ] as webmaster@company.com
DEBUG [b723a723] Command: [ -L /var/www/website/releases/20160301105814/log ]
DEBUG [b723a723] Finished in 0.086 seconds with exit status 1 (failed).
DEBUG [3443bee9] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/log ] as webmaster@company.com
DEBUG [3443bee9] Command: [ -d /var/www/website/releases/20160301105814/log ]
DEBUG [3443bee9] Finished in 0.084 seconds with exit status 1 (failed).
INFO [864f0e99] Running /usr/bin/env ln -s /var/www/website/shared/log /var/www/website/releases/20160301105814/log as webmaster@company.com
DEBUG [864f0e99] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/log /var/www/website/releases/20160301105814/log )
INFO [864f0e99] Finished in 0.089 seconds with exit status 0 (successful).
DEBUG [790e1b77] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/tmp/pids ] as webmaster@company.com
DEBUG [790e1b77] Command: [ -L /var/www/website/releases/20160301105814/tmp/pids ]
DEBUG [790e1b77] Finished in 0.091 seconds with exit status 1 (failed).
DEBUG [7ff98979] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/tmp/pids ] as webmaster@company.com
DEBUG [7ff98979] Command: [ -d /var/www/website/releases/20160301105814/tmp/pids ]
DEBUG [7ff98979] Finished in 0.092 seconds with exit status 1 (failed).
INFO [bcacf055] Running /usr/bin/env ln -s /var/www/website/shared/tmp/pids /var/www/website/releases/20160301105814/tmp/pids as webmaster@company.com
DEBUG [bcacf055] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/tmp/pids /var/www/website/releases/20160301105814/tmp/pids )
INFO [bcacf055] Finished in 0.096 seconds with exit status 0 (successful).
DEBUG [84ce523e] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/tmp/cache ] as webmaster@company.com
DEBUG [84ce523e] Command: [ -L /var/www/website/releases/20160301105814/tmp/cache ]
DEBUG [84ce523e] Finished in 0.337 seconds with exit status 1 (failed).
DEBUG [e6cf3b8d] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/tmp/cache ] as webmaster@company.com
DEBUG [e6cf3b8d] Command: [ -d /var/www/website/releases/20160301105814/tmp/cache ]
DEBUG [e6cf3b8d] Finished in 0.092 seconds with exit status 1 (failed).
INFO [087875ef] Running /usr/bin/env ln -s /var/www/website/shared/tmp/cache /var/www/website/releases/20160301105814/tmp/cache as webmaster@company.com
DEBUG [087875ef] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/tmp/cache /var/www/website/releases/20160301105814/tmp/cache )
INFO [087875ef] Finished in 0.102 seconds with exit status 0 (successful).
DEBUG [a25556fa] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/tmp/sockets ] as webmaster@company.com
DEBUG [a25556fa] Command: [ -L /var/www/website/releases/20160301105814/tmp/sockets ]
DEBUG [a25556fa] Finished in 0.100 seconds with exit status 1 (failed).
DEBUG [b8f01ed0] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/tmp/sockets ] as webmaster@company.com
DEBUG [b8f01ed0] Command: [ -d /var/www/website/releases/20160301105814/tmp/sockets ]
DEBUG [b8f01ed0] Finished in 0.093 seconds with exit status 1 (failed).
INFO [19a28b67] Running /usr/bin/env ln -s /var/www/website/shared/tmp/sockets /var/www/website/releases/20160301105814/tmp/sockets as webmaster@company.com
DEBUG [19a28b67] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/tmp/sockets /var/www/website/releases/20160301105814/tmp/sockets )
INFO [19a28b67] Finished in 0.095 seconds with exit status 0 (successful).
DEBUG [06a1d8ca] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/vendor/bundle ] as webmaster@company.com
DEBUG [06a1d8ca] Command: [ -L /var/www/website/releases/20160301105814/vendor/bundle ]
DEBUG [06a1d8ca] Finished in 0.089 seconds with exit status 1 (failed).
DEBUG [dec00a8c] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/vendor/bundle ] as webmaster@company.com
DEBUG [dec00a8c] Command: [ -d /var/www/website/releases/20160301105814/vendor/bundle ]
DEBUG [dec00a8c] Finished in 0.083 seconds with exit status 1 (failed).
INFO [3627ac6b] Running /usr/bin/env ln -s /var/www/website/shared/vendor/bundle /var/www/website/releases/20160301105814/vendor/bundle as webmaster@company.com
DEBUG [3627ac6b] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/vendor/bundle /var/www/website/releases/20160301105814/vendor/bundle )
INFO [3627ac6b] Finished in 0.092 seconds with exit status 0 (successful).
DEBUG [146317e0] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/public/system ] as webmaster@company.com
DEBUG [146317e0] Command: [ -L /var/www/website/releases/20160301105814/public/system ]
DEBUG [146317e0] Finished in 0.087 seconds with exit status 1 (failed).
DEBUG [cb7118ee] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/public/system ] as webmaster@company.com
DEBUG [cb7118ee] Command: [ -d /var/www/website/releases/20160301105814/public/system ]
DEBUG [cb7118ee] Finished in 0.091 seconds with exit status 1 (failed).
INFO [aae2f5d3] Running /usr/bin/env ln -s /var/www/website/shared/public/system /var/www/website/releases/20160301105814/public/system as webmaster@company.com
DEBUG [aae2f5d3] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/public/system /var/www/website/releases/20160301105814/public/system )
INFO [aae2f5d3] Finished in 0.100 seconds with exit status 0 (successful).
DEBUG [08a0fb87] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/public/uploads ] as webmaster@company.com
DEBUG [08a0fb87] Command: [ -L /var/www/website/releases/20160301105814/public/uploads ]
DEBUG [08a0fb87] Finished in 0.095 seconds with exit status 1 (failed).
DEBUG [3e78a336] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/public/uploads ] as webmaster@company.com
DEBUG [3e78a336] Command: [ -d /var/www/website/releases/20160301105814/public/uploads ]
DEBUG [3e78a336] Finished in 0.094 seconds with exit status 1 (failed).
INFO [02f078fa] Running /usr/bin/env ln -s /var/www/website/shared/public/uploads /var/www/website/releases/20160301105814/public/uploads as webmaster@company.com
DEBUG [02f078fa] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/public/uploads /var/www/website/releases/20160301105814/public/uploads )
INFO [02f078fa] Finished in 0.093 seconds with exit status 0 (successful).
DEBUG [7c8f085e] Running /usr/bin/env [ -L /var/www/website/releases/20160301105814/public/assets ] as webmaster@company.com
DEBUG [7c8f085e] Command: [ -L /var/www/website/releases/20160301105814/public/assets ]
DEBUG [7c8f085e] Finished in 0.092 seconds with exit status 1 (failed).
DEBUG [dfe9ba24] Running /usr/bin/env [ -d /var/www/website/releases/20160301105814/public/assets ] as webmaster@company.com
DEBUG [dfe9ba24] Command: [ -d /var/www/website/releases/20160301105814/public/assets ]
DEBUG [dfe9ba24] Finished in 0.095 seconds with exit status 1 (failed).
INFO [6e122bb3] Running /usr/bin/env ln -s /var/www/website/shared/public/assets /var/www/website/releases/20160301105814/public/assets as webmaster@company.com
DEBUG [6e122bb3] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/shared/public/assets /var/www/website/releases/20160301105814/public/assets )
INFO [6e122bb3] Finished in 0.100 seconds with exit status 0 (successful).
INFO [d6298e38] Running /usr/bin/env rm -rf /var/www/website/current as webmaster@company.com
DEBUG [d6298e38] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env rm -rf /var/www/website/current )
INFO [d6298e38] Finished in 0.098 seconds with exit status 0 (successful).
INFO [e02c789e] Running /usr/bin/env ln -s /var/www/website/releases/20160301105814 /var/www/website/current as webmaster@company.com
DEBUG [e02c789e] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ln -s /var/www/website/releases/20160301105814 /var/www/website/current )
INFO [e02c789e] Finished in 0.098 seconds with exit status 0 (successful).
DEBUG [eaafdb77] Running /usr/bin/env ls -x /var/www/website/releases as webmaster@company.com
DEBUG [eaafdb77] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env ls -x /var/www/website/releases )
DEBUG [eaafdb77]  20160301072751  20160301075427  20160301075935  20160301080340  20160301082251
20160301105814
DEBUG [eaafdb77] Finished in 0.099 seconds with exit status 0 (successful).
INFO Keeping 5 of 6 deployed releases on company.com
INFO [d4b13204] Running /usr/bin/env rm -rf /var/www/website/releases/20160301072751 as webmaster@company.com
DEBUG [d4b13204] Command: ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" ; /usr/bin/env rm -rf /var/www/website/releases/20160301072751 )
INFO [d4b13204] Finished in 0.123 seconds with exit status 0 (successful).
DEBUG [08ec3d12] Running /usr/bin/env if test ! -d /var/www/website/releases; then echo "Directory does not exist '/var/www/website/releases'" 1>&2; false; fi as webmaster@company.com
DEBUG [08ec3d12] Command: if test ! -d /var/www/website/releases; then echo "Directory does not exist '/var/www/website/releases'" 1>&2; false; fi
DEBUG [08ec3d12] Finished in 0.095 seconds with exit status 0 (successful).
INFO [18eda59c] Running /usr/bin/env echo "Branch master (at 41758f5) deployed as release 20160301105814 by alistair; " >> /var/www/website/revisions.log as webmaster@company.com
DEBUG [18eda59c] Command: echo "Branch master (at 41758f5) deployed as release 20160301105814 by alistair; " >> /var/www/website/revisions.log
INFO [18eda59c] Finished in 0.096 seconds with exit status 0 (successful).

[有效的解决方案]

宝石文件

group :development do
  gem 'capistrano', '~> 3.1.0'
  gem 'capistrano-bundler', '~> 1.1.2'
  gem 'capistrano-rails', '~> 1.1.1'
  gem 'capistrano-rbenv', '~> 2.0.4'
end

Capfile

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rbenv'
require 'capistrano/rails' # Same as requiring capistrano/bundler, capistrano/rails/assets and capistrano/rails/migrations

Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

config/deploy.rb

set :application, "website"

set :repo_url, "git@bitbucket.org:company/website.git"
set :deploy_to, "/var/www2/#{fetch(:application)}"

set :user, "webmaster"

set :rbenv_path, '/home/webmaster/.rbenv'
set :rbenv_ruby, '2.2.3'

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

set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads')
set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')

namespace :deploy do

  desc "Restart application"
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join("tmp/restart.txt")
    end
  end

  after "deploy:publishing", "deploy:restart"

end

config/deploy/production.rb

确保使用%w {}

set :stage, :production

server 'company.com', user: 'webmaster', roles: %w{web app db}

部署的输出

如果成功,您应该在输出中看到与此类似的内容:

If successful, you should see something similar to this in your output:

INFO [2412d16d] Running /home/webmaster/.rbenv/bin/rbenv exec bundle exec rake assets:precompile as webmaster@company.com
DEBUG [2412d16d] Command: cd /var/www/website/releases/20160302030846 && ( export RBENV_ROOT="/home/webmaster/.rbenv" RBENV_VERSION="2.2.3" RAILS_ENV="production" ; /home/webmaster/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )

推荐答案

由于拼写错误,您没有为服务器正确分配角色:

You've not assigned roles to your servers properly, due to a very subtle typo:

server 'company.com', user: 'webmaster', roles: %{web app db}

应该是:

server 'company.com', user: 'webmaster', roles: %w{web app db}

在Ruby中,%{}与双引号字符串相同,而%w{}是字符串数组.您需要后者,以便服务器具有三个角色webappdb,而不是一个名为web app db的角色.

In Ruby, %{} is the same as a double-quoted string, whereas %w{} is an array of strings. You want the latter, so that your server has the three roles, web, app, and db, not one role named web app db.

这篇关于Capistrano部署后未编译Rails资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆