Pergunta

So I am new with Capistrano and attempting to deploy my application with Capistrano.

Done a lot of Googling, really hard to figure out, all the docs I find, apply for older version of Capistrano and they seem to break compatibility with every other version.

But I stumbled upon a problem I can't seem to figure out by myself.

After Capistrano deploy, app assets link to wrong release folder and App just returns Missing template error.

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: ):

And indeed, the folder he is trying to access does not exist because the current release folder links to other release

current -> /var/fruby/releases/20140213100546

Notice how assets try accessing 20140213082235 and in reality, current release folder is 20140213100546. And if it helps, it seems that 20140213082235 stays always the same folder he tries to access over and over again, no matter how many times I run deploy.

Hell this release doesn't even exist in releases folder. There is just one single release (I cleaned up before).

For sake of argument, I deleted shared/bin, releases folder, and current symlink before this particular deploy.

Here is my 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'

and here is debug information Capistrano writes during deploy.

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

And if it is of any help, Nginx passenger server block

server {
    listen   80;
    server_name  somedomain.com;

    charset utf-8;
    root /var/fruby/current/public;
    passenger_enabled on;
    rails_env production;
}

Any help is very much appreciated.

Thank you in advance.

Foi útil?

Solução

The problem just went away, perhaps server restarting did work, although I SWEAR that I had restarted server before and it didn't work before.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top