Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:06:10+00:00 2026-05-28T16:06:10+00:00

I am using capistrano to deploy my rails application. I want to override the

  • 0

I am using capistrano to deploy my rails application. I want to override the deploy:assets:precompile task but I can’t manage to do that. Anyone know why this does not work? If it is not possible, is it possible to skip that deploy:assets:precompile is run every time I run deploy task?

This is my deploy.rb
load “config/domain.rb”

set :application, DOMAIN
set :repository, "..."
set :use_sudo, false
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache
set :user, "yomama"
set :port, 1337
set :scm, :git
set :normalize_asset_timestamps, false

role :web, "123.123.123.123"
role :app, "123.123.123.123"
role :db,  "123.123.123.123", primary: true

# RVM bootstrap
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, "1.9.2@#{application}"
set :rvm_type, :system
set :rvm_bin_path, "/usr/local/bin"

# bundler bootstrap
require "bundler/capistrano"

namespace :deploy do
  desc "Zero-downtime restart of Unicorn"
  task :restart, :except => { :no_release => true } do
    run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
  end

  desc "Start unicorn"
  task :start, :except => { :no_release => true } do
    run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D -E production"
  end

  desc "Stop unicorn"
  task :stop, :except => { :no_release => true } do
    run "kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
  end  

  desc "symlink shared files between releases"
  task :symlink_shared, :roles => :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
        run "ln -nfs #{shared_path}/assets #{release_path}/assets"
    run "ln -nfs #{shared_path}/public/uploads #{release_path}/public/uploads"
        # run "ln -nfs #{shared_path}/log/production.log #{release_path}/log/production.log"
  end

  namespace :assets do
    desc "Precompile assets only if it is needed"
    task :precompile, :roles => :web, :except => { :no_release => true } do
      from = source.next_revision(current_revision)
      run "cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l"
      if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ lib/assets/ app/assets/ | wc -l").to_i > 0
        run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
      else
        logger.info "Skipping asset pre-compilation because there were no asset changes"
      end
    end
  end
end

desc "tail production log files" 
task :tail_logs, :roles => :app do
  run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
    trap("INT") { puts 'Interupted'; exit 0; } 
    puts  # for an extra line break before the host name
    puts "#{channel[:host]}: #{data}" 
    break if stream == :err
  end
end

after "deploy:update_code", "deploy:symlink_shared"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:06:11+00:00Added an answer on May 28, 2026 at 4:06 pm

    I am stupid! I was loading files in the wrong order i my capfile.

    Before:

    load 'deploy' if respond_to?(:namespace) # cap2 differentiator
    Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
    load 'config/deploy' # remove this line to skip loading any of the default tasks
    # Uncomment if you are using Rails' asset pipeline
    load 'deploy/assets'
    

    After:

    load 'deploy' if respond_to?(:namespace) # cap2 differentiator
    Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
    # Uncomment if you are using Rails' asset pipeline
    load 'deploy/assets'
    load 'config/deploy' # remove this line to skip loading any of the default tasks
    

    Now it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a rails application in subversion that we deploy with Capistrano but have
I am currently deploying a Rails application using Capistrano. Cap deploy:update_code usually works just
I want to deploy a website the first time using Rails 3.2.1 with capistrano
I'm trying to deploy my rails application by using Passenger and Capistrano on Dreamhost.
I am trying to deploy my rails application to a server using capistrano and
I'm attempting to deploy my rails application w/ puma using Capistrano. Towards the end
I am using Capistrano to deploy my Rails application. whenever I deploy, changes would
I am using capistrano to deploy my rails app into my ec2 server but
So I am using Capistrano to deploy a rails application to my production server
While using Capistrano for deployment every time that I deploy I find that Rails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.