capistrano: Duplicate Output in log debug pretty

I’ve seen this lots of mentions of this without a clear solution.

I’m experiencing duplicate output in the log when running a staged deployments.

Here’s my log:

INFO [abd4b2ba] Running /usr/bin/env mkdir -p /tmp/take5/ as newismco@eepau1-02.nexcess.net
INFO [abd4b2ba] Finished in 0.510 seconds with exit status 0 (successful).
INFO Uploading /tmp/take5/git-ssh.sh 100.0%
INFO [94e1f157] Running /usr/bin/env chmod +x /tmp/take5/git-ssh.sh as newismco@eepau1-02.nexcess.net
INFO [94e1f157] Finished in 0.090 seconds with exit status 0 (successful).
INFO [8c55a5f6] Running /usr/bin/env mkdir -p /tmp/take5/ as newismco@eepau1-02.nexcess.net
INFO [8c55a5f6] Finished in 0.102 seconds with exit status 0 (successful).
INFO Uploading /tmp/take5/git-ssh.sh 100.0%
INFO [8ef265f0] Running /usr/bin/env chmod +x /tmp/take5/git-ssh.sh as newismco@eepau1-02.nexcess.net
INFO [8ef265f0] Finished in 0.075 seconds with exit status 0 (successful).
Please enter branch (master): 
INFO [bd0e8af3] Running /usr/bin/env git ls-remote --heads git@github.com:newism/take5.git as newismco@eepau1-02.nexcess.net
INFO [bd0e8af3] Finished in 3.681 seconds with exit status 0 (successful).
INFO [2e1529c6] Running /usr/bin/env git ls-remote --heads git@github.com:newism/take5.git as newismco@eepau1-02.nexcess.net
INFO [2e1529c6] Finished in 3.685 seconds with exit status 0 (successful).
INFO [4ed7024d] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/shared ~/take5.ncig.com.au/releases as newismco@eepau1-02.nexcess.net
INFO [4ed7024d] Finished in 0.077 seconds with exit status 0 (successful).
INFO [7ea7099e] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/shared/var/logs ~/take5.ncig.com.au/shared/var/cache ~/take5.ncig.com.au/shared/web/uploads ~/take5.ncig.com.au/shared/web/static ~/take5.ncig.com.au/shared/app/../vendor ~/take5.ncig.com.au/shared/app/../bin ~/take5.ncig.com.au/shared/var/logs ~/take5.ncig.com.au/shared/var/cache ~/take5.ncig.com.au/shared/web/uploads ~/take5.ncig.com.au/shared/web/static ~/take5.ncig.com.au/shared/app/../vendor ~/take5.ncig.com.au/shared/app/../bin ~/take5.ncig.com.au/shared/var/logs ~/take5.ncig.com.au/shared/var/cache ~/take5.ncig.com.au/shared/web/uploads ~/take5.ncig.com.au/shared/web/static ~/take5.ncig.com.au/shared/app/../vendor ~/take5.ncig.com.au/shared/app/../bin as newismco@eepau1-02.nexcess.net
INFO [7ea7099e] Finished in 0.081 seconds with exit status 0 (successful).
INFO [6a5f8c28] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/shared/app/config ~/take5.ncig.com.au/shared/app/config ~/take5.ncig.com.au/shared/app/config as newismco@eepau1-02.nexcess.net
INFO [6a5f8c28] Finished in 0.078 seconds with exit status 0 (successful).
INFO The repository mirror is at ~/take5.ncig.com.au/repo
INFO The repository mirror is at ~/take5.ncig.com.au/repo
INFO [898be8a0] Running /usr/bin/env git remote update as newismco@eepau1-02.nexcess.net
INFO [898be8a0] Finished in 3.757 seconds with exit status 0 (successful).
INFO [abff9643] Running /usr/bin/env git remote update as newismco@eepau1-02.nexcess.net
INFO [abff9643] Finished in 3.921 seconds with exit status 0 (successful).
INFO [129a1760] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/releases/20150515094355 as newismco@eepau1-02.nexcess.net
INFO [129a1760] Finished in 0.073 seconds with exit status 0 (successful).
INFO [18b7b7ee] Running /usr/bin/env git archive master | tar -x -f - -C ~/take5.ncig.com.au/releases/20150515094355 as newismco@eepau1-02.nexcess.net
INFO [18b7b7ee] Finished in 0.263 seconds with exit status 0 (successful).
INFO [8e33ac1d] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/releases/20150515094355 as newismco@eepau1-02.nexcess.net
INFO [8e33ac1d] Finished in 0.076 seconds with exit status 0 (successful).
INFO [d1305d9f] Running /usr/bin/env git archive master | tar -x -f - -C ~/take5.ncig.com.au/releases/20150515094355 as newismco@eepau1-02.nexcess.net
INFO [d1305d9f] Finished in 0.289 seconds with exit status 0 (successful).
INFO [3ccf7366] Running /usr/bin/env echo "1d441b5" >> REVISION as newismco@eepau1-02.nexcess.net
INFO [3ccf7366] Finished in 0.077 seconds with exit status 0 (successful).
INFO [6f4fe243] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/releases/20150515094355/app/config ~/take5.ncig.com.au/releases/20150515094355/app/config ~/take5.ncig.com.au/releases/20150515094355/app/config as newismco@eepau1-02.nexcess.net
INFO [6f4fe243] Finished in 0.075 seconds with exit status 0 (successful).
INFO [125ab89c] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/app/config/parameters.json ~/take5.ncig.com.au/releases/20150515094355/app/config/parameters.json as newismco@eepau1-02.nexcess.net
INFO [125ab89c] Finished in 0.073 seconds with exit status 0 (successful).
INFO [1e2b36fe] Running /usr/bin/env mkdir -p ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/app/.. ~/take5.ncig.com.au/releases/20150515094355/app/.. ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/app/.. ~/take5.ncig.com.au/releases/20150515094355/app/.. ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/var ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/20150515094355/app/.. ~/take5.ncig.com.au/releases/20150515094355/app/.. as newismco@eepau1-02.nexcess.net
INFO [1e2b36fe] Finished in 0.087 seconds with exit status 0 (successful).
INFO [1ba32579] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/var/logs ~/take5.ncig.com.au/releases/20150515094355/var/logs as newismco@eepau1-02.nexcess.net
INFO [1ba32579] Finished in 0.076 seconds with exit status 0 (successful).
INFO [4f7bde7d] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/var/cache ~/take5.ncig.com.au/releases/20150515094355/var/cache as newismco@eepau1-02.nexcess.net
INFO [4f7bde7d] Finished in 0.074 seconds with exit status 0 (successful).
INFO [014fc8d8] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/web/uploads ~/take5.ncig.com.au/releases/20150515094355/web/uploads as newismco@eepau1-02.nexcess.net
INFO [014fc8d8] Finished in 0.074 seconds with exit status 0 (successful).
INFO [dfead7e5] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/web/static ~/take5.ncig.com.au/releases/20150515094355/web/static as newismco@eepau1-02.nexcess.net
INFO [dfead7e5] Finished in 0.156 seconds with exit status 0 (successful).
INFO [d109171c] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/app/../vendor ~/take5.ncig.com.au/releases/20150515094355/app/../vendor as newismco@eepau1-02.nexcess.net
INFO [d109171c] Finished in 0.114 seconds with exit status 0 (successful).
INFO [941e8cf3] Running /usr/bin/env ln -s ~/take5.ncig.com.au/shared/app/../bin ~/take5.ncig.com.au/releases/20150515094355/app/../bin as newismco@eepau1-02.nexcess.net
INFO [941e8cf3] Finished in 0.130 seconds with exit status 0 (successful).
INFO [a231316a] Running php ~/take5.ncig.com.au/shared/composer.phar install  --no-interaction --optimize-autoloader as newismco@eepau1-02.nexcess.net
INFO [a231316a] Finished in 40.863 seconds with exit status 0 (successful).
INFO [f9399212] Running /usr/bin/env ln -s ~/take5.ncig.com.au/releases/20150515094355 ~/take5.ncig.com.au/releases/html as newismco@eepau1-02.nexcess.net
INFO [f9399212] Finished in 0.073 seconds with exit status 0 (successful).
INFO [c2753fe6] Running /usr/bin/env mv ~/take5.ncig.com.au/releases/html ~/take5.ncig.com.au as newismco@eepau1-02.nexcess.net
INFO [c2753fe6] Finished in 0.075 seconds with exit status 0 (successful).
INFO [5bb087fc] Running /usr/bin/env ln -s ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/html as newismco@eepau1-02.nexcess.net
INFO [5bb087fc] Finished in 0.073 seconds with exit status 0 (successful).
INFO [0ee45cc0] Running /usr/bin/env mv ~/take5.ncig.com.au/releases/html ~/take5.ncig.com.au as newismco@eepau1-02.nexcess.net
INFO [0ee45cc0] Finished in 0.075 seconds with exit status 0 (successful).
INFO [5005fff9] Running /usr/bin/env ln -s ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/html as newismco@eepau1-02.nexcess.net
INFO [5005fff9] Finished in 0.076 seconds with exit status 0 (successful).
INFO [b56c26e8] Running /usr/bin/env mv ~/take5.ncig.com.au/releases/html ~/take5.ncig.com.au as newismco@eepau1-02.nexcess.net
INFO [b56c26e8] Finished in 0.079 seconds with exit status 0 (successful).
INFO [822d4f3a] Running /usr/bin/env ln -s ~/take5.ncig.com.au/releases/20150515094355/web ~/take5.ncig.com.au/releases/html as newismco@eepau1-02.nexcess.net
INFO [822d4f3a] Finished in 0.074 seconds with exit status 0 (successful).
INFO [e33d9a9c] Running /usr/bin/env mv ~/take5.ncig.com.au/releases/html ~/take5.ncig.com.au as newismco@eepau1-02.nexcess.net
INFO [e33d9a9c] Finished in 0.077 seconds with exit status 0 (successful).
INFO Keeping 5 of 6 deployed releases on eepau1-02.nexcess.net
INFO [0c209742] Running /usr/bin/env rm -rf ~/take5.ncig.com.au/releases/20150515092223 as newismco@eepau1-02.nexcess.net
INFO [0c209742] Finished in 0.144 seconds with exit status 0 (successful).
INFO [841e0722] Running /usr/bin/env echo "Branch master (at 1d441b5) deployed as release 20150515094355 by leevigraham" >> ~/take5.ncig.com.au/revisions.log as newismco@eepau1-02.nexcess.net
INFO [841e0722] Finished in 0.073 seconds with exit status 0 (successful).

My Capfile

set :deploy_config_path, 'config/deploy/deploy.rb'
set :stage_config_path, 'config/deploy'

require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/composer'

My deploy.rb


# config valid only for current version of Capistrano
lock '3.4.0'

set :application, 'take5'
set :repo_url, 'git@github.com:newism/take5.git'

set :app_path,              "app"
set :web_path,              "web"
set :log_path,              "var/logs"
set :cache_path,            "var/cache"
set :composer_install_flags, ' --no-interaction --optimize-autoloader'

ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp

set :deploy_to, '~/take5.ncig.com.au'
set :log_level, :info
set :linked_files, fetch(:linked_files, []).push(fetch(:app_path) + '/config/parameters.json')
set :linked_dirs, fetch(:linked_dirs, []).push(fetch(:log_path), fetch(:cache_path), fetch(:web_path) + '/uploads', fetch(:web_path) + '/static', fetch(:app_path) + '/../vendor', fetch(:app_path) + '/../bin')
set :file_permissions_paths, [fetch(:log_path), fetch(:cache_path), fetch(:web_path) + '/uploads']
set :file_permissions_users, ["www-data"]

SSHKit.config.command_map[:composer] = "php #{shared_path.join("composer.phar")}"

namespace :git do
  task :update_repo_url do
    on roles(:all) do
      within repo_path do
        execute :git, 'remote', 'set-url', 'origin', fetch(:repo_url)
      end
    end
  end
end

module Capistrano
  module DSL
    module Paths
      def current_path
        deploy_path.join('html')
      end
    end
  end
end

namespace :deploy do
  namespace :symlink do
    desc 'Symlink release to current'
    task :release do
      on release_roles :all do
        tmp_current_path = release_path.parent.join(current_path.basename)
        execute :ln, '-s', release_path . join("web"), tmp_current_path
        execute :mv, tmp_current_path, current_path.parent
      end
    end
  end
end

and finally my production.rb


# server-based syntax
# ======================
# Defines a single server with a list of roles and multiple properties.
# You can define all roles on a single server, or split them:

server 'eepau1-02.nexcess.net', user: 'newismco', roles: %w{web}, my_property: :my_value

# server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
# server 'db.example.com', user: 'deploy', roles: %w{db}

# role-based syntax
# ==================

# Defines a role with one or multiple servers. The primary server in each
# group is considered to be the first unless any  hosts have the primary
# property set. Specify the username and a domain or IP for the server.
# Don't use `:all`, it's a meta role.

# role :app, %w{deploy@example.com}, my_property: :my_value
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
# role :db,  %w{deploy@example.com}

# Configuration
# =============
# You can set any configuration variable like in config/deploy.rb
# These variables are then only loaded and set in this stage.
# For available Capistrano configuration variables see the documentation page.
# http://capistranorb.com/documentation/getting-started/configuration/
# Feel free to add new variables to customise your setup.



# Custom SSH Options
# ==================
# You may pass any option but keep in mind that net/ssh understands a
# limited set of options, consult the Net::SSH documentation.
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
#
# Global options
# --------------
#  set :ssh_options, {
#    keys: %w(/home/rlisowski/.ssh/id_rsa),
#    forward_agent: false,
#    auth_methods: %w(password)
#  }
#
# The server-based syntax can be used to override options:
# ------------------------------------
# server 'eepau1-02.nexcess.net',
#  user: 'newismco',
#  roles: %w{web app},
#  ssh_options: {
#     user: 'user_name', # overrides user setting above
#     keys: %w(/home/user_name/.ssh/id_rsa),
#     forward_agent: false,
#     auth_methods: %w(publickey password)
#     # password: 'please use keys'
#  }

My Gemfile

source "https://rubygems.org"

gem 'capistrano', '~> 3.4.0'
gem 'capistrano-file-permissions'
gem 'capistrano-composer'

gem 'scss-lint', '~> 0.35.0'

Any help would be appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (14 by maintainers)

Most upvoted comments

@leevigraham I think I see your problem:

set :deploy_config_path, 'config/deploy/deploy.rb'
set :stage_config_path, 'config/deploy'

^ This is trouble.

You’ve told Capistrano that your stage definitions are in the config/deploy directory. But you also have a file called deploy.rb there, in addition to your stages.

Capistrano is going to assume deploy.rb represents a stage, and will create a corresponding Rake task called deploy to load that stage. But of course deploy already means something else in Capistrano-land! So when you run deploy, you are doubling up on behavior. I imaging this could lead to a scenario where certain things happen twice.

Takeaways:

  1. Do not put any .rb files in the stages directory other than your actual stage definitions.
  2. Avoid using Capistrano task names as your stage filenames. For example, deploy and rollback are bad names for stages. 😉

@matthutchinson In your case, I think you have a problem in production.rb. You’ve specified a port number in one role declaration, but not the others. Capistrano is probably interpreting this as you declaring two distinct servers.

Perhaps just a failsafe that prevents a stage from overriding/augmenting an existing task?

 stages.each do |stage|
+  raise %Q("#{stage}" cannot be used as a stage name) if Rake::Task.task_defined?(stage)
   Rake::Task.define_task(stage) do
     set(:stage, stage.to_sym)