1

I am running rake tasks on the server using a snippet like the following in the deploy.rb of a rails app.

  desc 'Invoke rake task on the server'
  task :invoke do
    fail 'no task provided' unless ENV['task']

    on roles(:app) do
      within release_path do
        with rails_env: fetch(:rails_env) do
          execute :rake, ENV['task']
        end
      end
    end
  end

The rake task runs ok but I would like to see the output from the rake task displayed in the console where I run the capistrano task.

puts commands in the rake task do not appear.

giorgio
  • 2,115
  • 5
  • 23
  • 39
  • I just found that it depends on the server. On my staging server there is no output returned whereas on my production server there is output ... – giorgio Aug 21 '15 at 07:02

1 Answers1

0

If in Debug mode, capistrano prints out the outputs of the commands if I'm not mistaken. Probably you set your log level to :info. Just find the line in your deploy.rb and change it to (add it if its not there):

set :log_level, :debug

If you want to have this only for the single command or I was wrong and the above solution does not work for you, maybe checkout this answer (dunno if its still working): Capistrano log level

UPDATE: How about using Rails logger instead of puts in the game task:

Rails.logger.debug "test"
Community
  • 1
  • 1
smallbutton
  • 3,377
  • 15
  • 27
  • It is already in debug mode but no output is shown from rake. Interestingly the output from dB:migrate IS shown . – giorgio Aug 20 '15 at 20:49
  • have you tried the second solution that is linked in my answer. Looks quite similar to what you need. – smallbutton Aug 20 '15 at 23:11
  • Makes no difference the capistrano log level is already set to debug. I tried it out of interest but it made no difference. I do get an output saying the rake task is run "DEBUG [4b23c943] Rake test run at 2015-08-21 12:43:08 +1200" but not the output from my "put" statements in the rake task. – giorgio Aug 21 '15 at 00:45