Problems with Resque Magazine

I added Resque to my Rails 3 project. I created a work that reads / writes some things from / to the database.

The problem is that I do not see SQL query logs such as "Post Load (0.5ms) SELECT" posts ". * FROM" posts "" in the terminal anymore. I also do not see any Rails.logger messages I created.

When I make another query (simple update), log messages and SQL query logs will appear.

Any ideas what could be? Thanks

+6
source share
3 answers

Rails will not be written to the log file immediately, it expects a certain number of lines to pass before you clear the file. You can tell Rails to always clear the log by adding it to your development.rb or application.rb file ...

 config.logger.auto_flushing = true 

Only ever do it in development and never install it in the production process, as it will just kill your I / O.

You can also do this on demand using ...

 Rails.logger.flush 

API documentation here ...

http://api.rubyonrails.org/classes/ActiveSupport/BufferedLogger.html#method-i-auto_flushing-3D

+4
source

We faced the same problem in one of our projects. In addition, we also wanted to register all Resque messages in a separate log file.

You can find sample code in the Include instant messages from resque workers journal blog post to include immediate logging in a separate file.

+2
source

Resque will not clear the log in production mode (unless your job generates more than 1000 log lines).

You will need to clear each line of the generated log. I would configure only resque with the file lib / tasks / resque.rake:

 task "resque:setup" => :environment do Resque.before_first_fork = Proc.new { Rails.logger.auto_flushing = 1 } end 
0
source

Source: https://habr.com/ru/post/891554/


All Articles