I have a server using Ruby, Sinatra, Unicorn and nginx. I experienced a crash recently, which re-producing the issue while running in Terminal, I can see it produces this crash log:
/Users/Andrew/.rvm/gems/ruby-2.3.0/gems/tweetstream-2.6.1/lib/tweetstream/client.rb:449:in `block in connect': Failed to reconnect after 6 tries. (TweetStream::ReconnectError)
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/em-twitter-0.3.5/lib/em-twitter/connection.rb:297:in `invoke_callback'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/em-twitter-0.3.5/lib/em-twitter/connection.rb:269:in `rescue in schedule_reconnect'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/em-twitter-0.3.5/lib/em-twitter/connection.rb:264:in `schedule_reconnect'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/em-twitter-0.3.5/lib/em-twitter/connection.rb:92:in `unbind'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:1483:in `event_callback'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run_machine'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:194:in `run'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/backends/base.rb:73:in `start'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/thin-1.7.0/lib/thin/server.rb:162:in `start'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/rack-1.6.4/lib/rack/handler/thin.rb:19:in `run'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1506:in `start_server'
from /Users/Andrew/.rvm/gems/ruby-2.3.0/gems/sinatra-1.4.7/lib/sinatra/base.rb:1444:in `run!'
from server.rb:234:in `<main>'
But when I was looking for an error log earlier, I couldn't find anything like the above.
My /etc/nginx/nginx.conf file shows this as the location of the logs:
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
But I go to both of those directories, and the access log just displays all the requests, as I'd expect, and the error log is empty.
If my logs are being stored elsewhere, how can I determine where that is? Or if it's for some reason not logging crashes, how can I ensure it is?
I would suggest you set a stderr
and stdout
logs for unicorn in the unicorn.rb
file.
# set path to app that will be used to configure unicorn,
# note the trailing slash in this example
@dir = File.dirname(__FILE__) + '/'
worker_processes 2
working_directory @dir
timeout 30
# Specify path to socket unicorn listens to,
# we will use this in our nginx.conf later
listen "/home/vagrant/sockets/unicorn.sock", :backlog => 64
# Set process id path
pid "#{@dir}tmp/pids/unicorn.pid"
# Set log file paths
stderr_path "/var/log/unicorn/stderr.log"
stdout_path "/var/log/unicorn/stdout.log"