gpt4 book ai didi

ruby-on-rails - Capistrano 部署后 Rails Assets 未编译

转载 作者:行者123 更新时间:2023-12-04 06:33:35 25 4
gpt4 key购买 nike

我正在使用 Capistrano 部署我的 Rails 应用程序,似乎 Assets 没有被编译,除非我 ssh 进入服务器并手动运行 RAILS_ENV=development bundle exec rake assets:precompile

我已尝试按照 the capistrano/rails github page 上的说明进行操作,但我不确定我是否遗漏了什么。

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

版本

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}

关于 Assets 未编译的任何想法?

[更新]

部署输出

/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).

[工作解决方案]

gem 文件

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}

部署输出

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

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 )

最佳答案

由于一个非常微妙的拼写错误,您没有正确地为您的服务器分配角色:

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

应该是:

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

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

关于ruby-on-rails - Capistrano 部署后 Rails Assets 未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35718268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com