Last Updated: February 25, 2016
·
1.78K
· exreanimator

Capistrano 3, show task output (if logger level is info by default)

# deploy.rb
def with_verbosity(verbosity_level)
  old_verbosity = SSHKit.config.output_verbosity
  begin
    SSHKit.config.output_verbosity = verbosity_level
    yield
  ensure
    SSHKit.config.output_verbosity = old_verbosity
  end
end
# task
namespace :thor do
  desc "Run task"
  task :execute do
    on roles(:app) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          with_verbosity(Logger::DEBUG) do
            execute :bundle, :exec, :thor, ENV['taskname']
          end
        end
      end
    end
  end
end