所以我是Capistrano的新手,并试图用Capistrano部署我的应用程序。
做了很多谷歌搜索,真的很难弄明白,我找到的所有文档,申请旧版本的Capistrano,它们似乎打破了与其他所有版本的兼容性。
但我偶然发现了一个我自己似乎无法解决的问题。
Capistrano部署后,应用资产链接到错误的发布文件夹,App只返回Missing模板错误。
App 30962 stderr: ActionView::MissingTemplate (Missing template layouts/main_page with {:locale=>[:ru], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
App 30962 stderr: * "/var/fruby/releases/20140213082235/app/views"
App 30962 stderr: * "/var/fruby/shared/bundle/ruby/1.9.1/gems/devise-3.2.2/app/views"
App 30962 stderr: ):
实际上,他尝试访问的文件夹不存在,因为当前版本文件夹链接到其他版本
current -> /var/fruby/releases/20140213100546
请注意资产如何尝试访问 20140213082235 ,实际上,当前版本文件夹是 20140213100546 。如果它有帮助,似乎 20140213082235 总是与他试图一遍又一遍地访问的文件夹保持一致,无论我运行多少次部署。
地狱这个版本甚至不存在于release文件夹中。只有一个版本(我之前清理过)。
为了论证,我在此特定部署之前删除了shared / bin,releases文件夹和当前符号链接。
这是我的Capistrano deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
application_name = 'fruby'
set :use_sudo, true
set :application, application_name
set :repo_url, 'git@github.com:someuser/someapp.git'
# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
# Default deploy_to directory is /var/www/my_app
set :deploy_to, "/var/#{application_name}"
set :deploy_via, :remote_cache
set :rails_env, 'production'
set :scm, :git
set :format, :pretty
set :log_level, :debug
# Default value for linked_dirs is []
set :linked_dirs, %w{log tmp public}
# Default value for keep_releases is 5
set :keep_releases, 2
namespace :deploy do
task :fix_assets_permission do
on roles(:web), in: :sequence, wait: 5 do
execute "chown -R root:root /var/#{application_name}/shared/tmp/cache/;"
execute "chmod 777 -R /var/#{application_name}/shared/tmp/cache/;"
end
end
desc 'Restart application'
task :restart do
on roles(:web), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
end
after 'deploy:compile_assets', 'deploy:fix_assets_permission'
这是Capistrano在部署期间编写的调试信息。
INFO [8b5cf3f8] Running /usr/bin/env mkdir -p /tmp/fruby/ on somedomain.com
DEBUG [8b5cf3f8] Command: /usr/bin/env mkdir -p /tmp/fruby/
INFO [8b5cf3f8] Finished in 0.851 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/fruby/git-ssh.sh 0.0%
INFO Uploading /tmp/fruby/git-ssh.sh 100.0%
INFO [54bd7f1a] Running /usr/bin/env chmod +x /tmp/fruby/git-ssh.sh on somedomain.com
DEBUG [54bd7f1a] Command: /usr/bin/env chmod +x /tmp/fruby/git-ssh.sh
INFO [54bd7f1a] Finished in 0.102 seconds with exit status 0 (successful).
DEBUG [5f2c9b73] Running /usr/bin/env git ls-remote git@github.com:someuser/someapp.git on somedomain.com
DEBUG [5f2c9b73] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/fruby/git-ssh.sh /usr/bin/env git ls-remote git@github.com:someuser/someapp.git )
DEBUG [5f2c9b73] 13a3d2301d5e62bdb9af52a0798907ch47d43356 HEAD
DEBUG [5f2c9b73] 13a3d2301d5e62bdb9af52a0798907ch47d43356 refs/heads/master
DEBUG [5f2c9b73] Finished in 1.853 seconds with exit status 0 (successful).
INFO [0703251f] Running /usr/bin/env mkdir -pv /var/fruby/shared /var/fruby/releases on somedomain.com
DEBUG [0703251f] Command: /usr/bin/env mkdir -pv /var/fruby/shared /var/fruby/releases
DEBUG [0703251f] mkdir: created directory `/var/fruby/releases'
INFO [0703251f] Finished in 0.104 seconds with exit status 0 (successful).
INFO [12be6fbc] Running /usr/bin/env mkdir -pv /var/fruby/shared/log /var/fruby/shared/tmp /var/fruby/shared/public on somedomain.com
DEBUG [12be6fbc] Command: /usr/bin/env mkdir -pv /var/fruby/shared/log /var/fruby/shared/tmp /var/fruby/shared/public
INFO [12be6fbc] Finished in 0.104 seconds with exit status 0 (successful).
DEBUG [b985d99b] Running /usr/bin/env [ -f /var/fruby/repo/HEAD ] on somedomain.com
DEBUG [b985d99b] Command: [ -f /var/fruby/repo/HEAD ]
DEBUG [b985d99b] Finished in 0.100 seconds with exit status 0 (successful).
INFO The repository mirror is at /var/fruby/repo
DEBUG [353f5ba0] Running /usr/bin/env if test ! -d /var/fruby/repo; then echo "Directory does not exist '/var/fruby/repo'" 1>&2; false; fi on somedomain.com
DEBUG [353f5ba0] Command: if test ! -d /var/fruby/repo; then echo "Directory does not exist '/var/fruby/repo'" 1>&2; false; fi
DEBUG [353f5ba0] Finished in 0.100 seconds with exit status 0 (successful).
DEBUG [559df4f8] Running /usr/bin/env cd /var/fruby/repo && git rev-parse --short HEAD on somedomain.com
DEBUG [559df4f8] Command: cd /var/fruby/repo && git rev-parse --short HEAD
DEBUG [559df4f8] 13a3d23
DEBUG [559df4f8] Finished in 0.103 seconds with exit status 0 (successful).
INFO [1c6ade67] Running /usr/bin/env git remote update on somedomain.com
DEBUG [1c6ade67] Command: cd /var/fruby/repo && /usr/bin/env git remote update
DEBUG [1c6ade67] Fetching origin
INFO [1c6ade67] Finished in 1.995 seconds with exit status 0 (successful).
DEBUG [114fb8b6] Running /usr/bin/env cd /var/fruby/repo && git rev-parse --short HEAD on somedomain.com
DEBUG [114fb8b6] Command: cd /var/fruby/repo && git rev-parse --short HEAD
DEBUG [114fb8b6] 13a3d23
DEBUG [114fb8b6] Finished in 0.103 seconds with exit status 0 (successful).
DEBUG [4cead9f2] Running /usr/bin/env if test ! -d /var/fruby/repo; then echo "Directory does not exist '/var/fruby/repo'" 1>&2; false; fi on somedomain.com
DEBUG [4cead9f2] Command: if test ! -d /var/fruby/repo; then echo "Directory does not exist '/var/fruby/repo'" 1>&2; false; fi
DEBUG [4cead9f2] Finished in 0.100 seconds with exit status 0 (successful).
INFO [dcb034dc] Running /usr/bin/env mkdir -p /var/fruby/releases/20140213100546 on somedomain.com
DEBUG [dcb034dc] Command: cd /var/fruby/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/fruby/git-ssh.sh /usr/bin/env mkdir -p /var/fruby/releases/20140213100546 )
INFO [dcb034dc] Finished in 0.104 seconds with exit status 0 (successful).
INFO [e5ae8a9d] Running /usr/bin/env git archive master | tar -x -C /var/fruby/releases/20140213100546 on somedomain.com
DEBUG [e5ae8a9d] Command: cd /var/fruby/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/fruby/git-ssh.sh /usr/bin/env git archive master | tar -x -C /var/fruby/releases/20140213100546 )
INFO [e5ae8a9d] Finished in 1.267 seconds with exit status 0 (successful).
INFO [031a127d] Running /usr/bin/env mkdir -pv /var/fruby/releases/20140213100546 /var/fruby/releases/20140213100546 /var/fruby/releases/20140213100546 on somedomain.com
DEBUG [031a127d] Command: /usr/bin/env mkdir -pv /var/fruby/releases/20140213100546 /var/fruby/releases/20140213100546 /var/fruby/releases/20140213100546
INFO [031a127d] Finished in 0.103 seconds with exit status 0 (successful).
DEBUG [2869942a] Running /usr/bin/env [ -L /var/fruby/releases/20140213100546/log ] on somedomain.com
DEBUG [2869942a] Command: [ -L /var/fruby/releases/20140213100546/log ]
DEBUG [2869942a] Finished in 0.100 seconds with exit status 1 (failed).
DEBUG [d8054077] Running /usr/bin/env [ -d /var/fruby/releases/20140213100546/log ] on somedomain.com
DEBUG [d8054077] Command: [ -d /var/fruby/releases/20140213100546/log ]
DEBUG [d8054077] Finished in 0.099 seconds with exit status 1 (failed).
INFO [8ee1aa40] Running /usr/bin/env ln -s /var/fruby/shared/log /var/fruby/releases/20140213100546/log on somedomain.com
DEBUG [8ee1aa40] Command: /usr/bin/env ln -s /var/fruby/shared/log /var/fruby/releases/20140213100546/log
INFO [8ee1aa40] Finished in 0.103 seconds with exit status 0 (successful).
DEBUG [1c8e2ddf] Running /usr/bin/env [ -L /var/fruby/releases/20140213100546/tmp ] on somedomain.com
DEBUG [1c8e2ddf] Command: [ -L /var/fruby/releases/20140213100546/tmp ]
DEBUG [1c8e2ddf] Finished in 0.099 seconds with exit status 1 (failed).
DEBUG [29409e68] Running /usr/bin/env [ -d /var/fruby/releases/20140213100546/tmp ] on somedomain.com
DEBUG [29409e68] Command: [ -d /var/fruby/releases/20140213100546/tmp ]
DEBUG [29409e68] Finished in 0.099 seconds with exit status 1 (failed).
INFO [a0581377] Running /usr/bin/env ln -s /var/fruby/shared/tmp /var/fruby/releases/20140213100546/tmp on somedomain.com
DEBUG [a0581377] Command: /usr/bin/env ln -s /var/fruby/shared/tmp /var/fruby/releases/20140213100546/tmp
INFO [a0581377] Finished in 0.102 seconds with exit status 0 (successful).
DEBUG [9b010c55] Running /usr/bin/env [ -L /var/fruby/releases/20140213100546/public ] on somedomain.com
DEBUG [9b010c55] Command: [ -L /var/fruby/releases/20140213100546/public ]
DEBUG [9b010c55] Finished in 0.099 seconds with exit status 1 (failed).
DEBUG [04e2b790] Running /usr/bin/env [ -d /var/fruby/releases/20140213100546/public ] on somedomain.com
DEBUG [04e2b790] Command: [ -d /var/fruby/releases/20140213100546/public ]
DEBUG [04e2b790] Finished in 0.105 seconds with exit status 0 (successful).
INFO [869e3d51] Running /usr/bin/env rm -rf /var/fruby/releases/20140213100546/public on somedomain.com
DEBUG [869e3d51] Command: /usr/bin/env rm -rf /var/fruby/releases/20140213100546/public
INFO [869e3d51] Finished in 0.130 seconds with exit status 0 (successful).
INFO [60aeb659] Running /usr/bin/env ln -s /var/fruby/shared/public /var/fruby/releases/20140213100546/public on somedomain.com
DEBUG [60aeb659] Command: /usr/bin/env ln -s /var/fruby/shared/public /var/fruby/releases/20140213100546/public
INFO [60aeb659] Finished in 0.102 seconds with exit status 0 (successful).
DEBUG [c487b30d] Running /usr/bin/env if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi on somedomain.com
DEBUG [c487b30d] Command: if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi
DEBUG [c487b30d] Finished in 0.100 seconds with exit status 0 (successful).
INFO [7e4baf5b] Running /usr/bin/env bundle install --binstubs /var/fruby/shared/bin --path /var/fruby/shared/bundle --without development test --deployment --quiet on somedomain.com
DEBUG [7e4baf5b] Command: cd /var/fruby/releases/20140213100546 && /usr/bin/env bundle install --binstubs /var/fruby/shared/bin --path /var/fruby/shared/bundle --without development test --deployment --quiet
INFO [7e4baf5b] Finished in 1.808 seconds with exit status 0 (successful).
DEBUG [cac16d29] Running /usr/bin/env if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi on somedomain.com
DEBUG [cac16d29] Command: if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi
DEBUG [cac16d29] Finished in 0.096 seconds with exit status 0 (successful).
INFO [c4c22728] Running bundle exec rake assets:precompile on somedomain.com
DEBUG [c4c22728] Command: cd /var/fruby/releases/20140213100546 && ( RAILS_ENV=production bundle exec rake assets:precompile )
DEBUG [c4c22728] /usr/bin/ruby1.9.1 /var/fruby/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEBUG [c4c22728] [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
DEBUG [c4c22728] ** [Raven] Raven 0.7.1 ready to catch errors
DEBUG [c4c22728] [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
DEBUG [c4c22728] ** [Raven] Raven 0.7.1 ready to catch errors
DEBUG [c4c22728] [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
DEBUG [c4c22728] ** [Raven] Raven 0.7.1 ready to catch errors
DEBUG [c4c22728] [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
INFO [c4c22728] Finished in 213.492 seconds with exit status 0 (successful).
DEBUG [13f65310] Running /usr/bin/env if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi on somedomain.com
DEBUG [13f65310] Command: if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi
DEBUG [13f65310] Finished in 0.714 seconds with exit status 0 (successful).
INFO [2372bebc] Running /usr/bin/env cp /var/fruby/releases/20140213100546/public/assets/manifest* /var/fruby/releases/20140213100546/assets_manifest_backup on somedomain.com
DEBUG [2372bebc] Command: cd /var/fruby/releases/20140213100546 && /usr/bin/env cp /var/fruby/releases/20140213100546/public/assets/manifest* /var/fruby/releases/20140213100546/assets_manifest_backup
INFO [2372bebc] Finished in 0.106 seconds with exit status 0 (successful).
INFO [fd9ff012] Running /usr/bin/env chown -R root:root /var/fruby/shared/tmp/cache/; on somedomain.com
DEBUG [fd9ff012] Command: chown -R root:root /var/fruby/shared/tmp/cache/;
INFO [fd9ff012] Finished in 0.178 seconds with exit status 0 (successful).
INFO [4090c091] Running /usr/bin/env chmod 777 -R /var/fruby/shared/tmp/cache/; on somedomain.com
DEBUG [4090c091] Command: chmod 777 -R /var/fruby/shared/tmp/cache/;
INFO [4090c091] Finished in 0.180 seconds with exit status 0 (successful).
WARN [SKIPPING] No Matching Host for /usr/bin/env if test ! -d /var/fruby/releases/20140213100546; then echo "Directory does not exist '/var/fruby/releases/20140213100546'" 1>&2; false; fi
WARN [SKIPPING] No Matching Host for bundle exec rake db:migrate
INFO [a2e6371c] Running /usr/bin/env rm -rf /var/fruby/current on somedomain.com
DEBUG [a2e6371c] Command: /usr/bin/env rm -rf /var/fruby/current
INFO [a2e6371c] Finished in 0.102 seconds with exit status 0 (successful).
INFO [8081e6a1] Running /usr/bin/env ln -s /var/fruby/releases/20140213100546 /var/fruby/current on somedomain.com
DEBUG [8081e6a1] Command: /usr/bin/env ln -s /var/fruby/releases/20140213100546 /var/fruby/current
INFO [8081e6a1] Finished in 0.102 seconds with exit status 0 (successful).
DEBUG [d14a199e] Running /usr/bin/env ls -x /var/fruby/releases on somedomain.com
DEBUG [d14a199e] Command: /usr/bin/env ls -x /var/fruby/releases
DEBUG [d14a199e] 20140213100546
DEBUG [d14a199e] Finished in 0.103 seconds with exit status 0 (successful).
DEBUG [c681d69e] Running /usr/bin/env if test ! -d /var/fruby/releases; then echo "Directory does not exist '/var/fruby/releases'" 1>&2; false; fi on somedomain.com
DEBUG [c681d69e] Command: if test ! -d /var/fruby/releases; then echo "Directory does not exist '/var/fruby/releases'" 1>&2; false; fi
DEBUG [c681d69e] Finished in 0.099 seconds with exit status 0 (successful).
INFO [1e2e4a2e] Running /usr/bin/env echo "Branch master (at 13a3d23) deployed as release 20140213100546 by vitali; " >> /var/fruby/revisions.log on somedomain.com
DEBUG [1e2e4a2e] Command: echo "Branch master (at 13a3d23) deployed as release 20140213100546 by vitali; " >> /var/fruby/revisions.log
INFO [1e2e4a2e] Finished in 0.099 seconds with exit status 0 (successful).
如果有任何帮助,Nginx乘客服务器阻止
server {
listen 80;
server_name somedomain.com;
charset utf-8;
root /var/fruby/current/public;
passenger_enabled on;
rails_env production;
}
非常感谢任何帮助。
提前谢谢。
答案 0 :(得分:1)
问题刚刚消失,也许服务器重启确实有效,虽然我认为我之前已经重新启动了服务器而之前没有工作。