Humming
Humming

Reputation: 453

Unicorn application server log keeps ticking on its own

I have deployed my Rails app using Passenger-NGinx and Unicorn, but it gets really hard to check the logs because the log is constantly being hit (on the root path) all by its own, that is, even when there is no real incoming request. Not sure why this would happen. This also means that the log gets really big, really fast.

My unicorn.rb file looks like this:

# set path to application
tmp_dir = "/tmp"
app_dir = File.expand_path("../..", __FILE__)
shared_dir = "#{app_dir}/shared"
working_directory app_dir


# Set unicorn options
worker_processes 2
preload_app true
timeout 30

# Set up socket location
listen "#{shared_dir}/sockets/unicorn.sock", :backlog => 64

# Logging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"

# Set master PID location
pid "#{shared_dir}/pids/unicorn.pid"

Any helpful suggestions? Thanks!

Update:

It looks like this is an issue with Passenger itself. I removed Unicorn as the app server, now using Passenger, and Passenger log is having the same issue.

Upvotes: 1

Views: 501

Answers (1)

Anthony E
Anthony E

Reputation: 11235

It's hard to say what the source of traffic is without more information. Do you have a health check or ping that checks the status of your server? Is it possible that the traffic could be coming from bots or search spiders? If you're still not sure I'd consider listening on port 80 with tcpdump to see the IPs and other information about where the traffic may be originating.

In any case, if you want such requests to be excluded then you can write your own Rack middleware to exclude specific URLs or IPs from logging traffic. There's a more detailed blog article about it here: https://archive.dennisreimann.de/blog/silencing-the-rails-log-on-a-per-action-basis/.

You can also consider using Lograge which provides better control for logging than the default included with Rails: https://github.com/roidrage/lograge. With lograge, you can use the payload[:ip].reject syntax in your configuration to reject requests based on IP address or action: https://github.com/roidrage/lograge#what-it-doesnt-do.

Upvotes: 1

Related Questions