Rails assets aren't compiling after Capistrano deployment

故事扮演 提交于 2019-12-23 22:01:29

问题


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.

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

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.

Versions

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}

Any ideas why the assets aren't compiling?

[Update]

Output from deploy

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

[Working Solution]

Gemfile

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

Make sure to use %w{}

set :stage, :production

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

Output from deploy

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 )

回答1:


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

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

It should be:

server 'company.com', user: 'webmaster', roles: %w{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.



来源:https://stackoverflow.com/questions/35718268/rails-assets-arent-compiling-after-capistrano-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!