Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

App crashes because log/production.log doesn't exist #4

Open
nhocki opened this Issue September 25, 2011 · 14 comments

8 participants

Nicolás Hock Isaza Joe Ferraro rtekie georgegwu Rohit Joshi Ben Atkins Donn Felker Matt Sly
Nicolás Hock Isaza

I understand that Heroku uses this plugin to make the log go to STDOUT and not to a file. The problem is that this is crashing the app on boot.

When I deploy the app, I get (among other things)...

-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Preparing app for Rails asset pipeline
       Detected manifest.yml, assuming assets were compiled locally

But, the application crashes. The logs show this (Cleaning the date and stuff to make it more readable):

 State changed from crashed to created
 State changed from created to starting
 Slug compilation finished
 Starting process with command `bundle exec rails server -p 44487`
 => Booting WEBrick
 => Rails 3.1.0 application starting in production on http://0.0.0.0:44487
 => Call with -d to detach
 => Ctrl-C to shutdown server
 /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/rack/log_tailer.rb:8:in `size': No such file or directory - log/production.log (Errno::ENOENT)
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/rack/log_tailer.rb:8:in `initialize'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:295:in `new'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:295:in `block in build_app'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:291:in `reverse_each'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:291:in `build_app'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:301:in `wrapped_app'
    from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.3.3/lib/rack/server.rb:252:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands/server.rb:70:in `start'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:54:in `block in <top (required)>'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
    from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.0/lib/rails/commands.rb:49:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
    2011-09-25T20:16:05+00:00 heroku[web.1]: Process exited

I think this happens because the rails server command is not started with the daemonize option:

https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb#L79

So it loads this:

https://github.com/rails/rails/blob/master/railties/lib/rails/rack/log_tailer.rb#L8

Causing the problem in Line 8 (I think).

Any help?

Thanks

Nicolás Hock Isaza

Any idea why this happens? I can't push my app :-(

Joe Ferraro

having the same issue...

Nicolás Hock Isaza

It was a problem in my production.rb file. If you want, post it here and I'll try to help you :-)

rtekie

I run into the same issue when migrating an application from bamboo to cedar. I had these two lines in my production.rb:

config.logger = Logger.new(STDOUT) # required for logging to work in rake tasks
config.logger.level = Logger::INFO # required to stop debug logging on production

Removing them fixed the boot problem.

georgegwu

Any suggestion on what to do if I do want to see more detail logs? Some post on stackoverflow suggest to add code similar to these two lines to production.rb

http://stackoverflow.com/questions/8031007/how-to-increase-heroku-log-drain-verbosity-to-include-all-rails-app-details

Thanks,

Rohit Joshi

by any means i have not been able to solve this issue :-(
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:8:in `size': No such file or directory - log/production/production.log (Errno::ENOENT)
please help !!

Ben Atkins

@nhocki can you please give a more detailed explanation of what you needed to modify in your production.rb file to get it working? Posting it might help, but an explanation would be better!

I started receiving this problem after pushing an app to Heroku's cedar stack, and following the instructions here to use thin as the webserver. Here's a note that may be helpful to anyone struggling to get this working. Heroku suggests creating a file in the root of your rails application named Procfile with this as the contents:

web: bundle exec rails server thin -p $PORT -e $RACK_ENV/$RAILS_ENV

When I did that and tried to push to Heroku, my app crashed. Upon examining the log for the application I saw the same errors people are mentioning above here:

2012-03-07T22:06:47+00:00 app[web.1]: => Booting Thin
2012-03-07T22:06:47+00:00 app[web.1]: => Rails 3.2.2 application starting in production on http://0.0.0.0:48284
2012-03-07T22:06:47+00:00 app[web.1]: => Call with -d to detach
2012-03-07T22:06:47+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-03-07T22:06:47+00:00 app[web.1]: Exiting
2012-03-07T22:06:47+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/rack/log_tailer.rb:8:in `size': No such file or directory - log/production/production.log (Errno::ENOENT)
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/rack/log_tailer.rb:8:in `initialize'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:295:in `new'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:295:in `block in build_app'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `

2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:291:in `reverse_each'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:291:in `build_app'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands/server.rb:70:in `start'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:55:in `block in <top (required)>'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `tap'
2012-03-07T22:06:47+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in `<top (required)>'
2012-03-07T22:06:47+00:00 app[web.1]:   from script/rails:6:in `require'
2012-03-07T22:06:47+00:00 app[web.1]:   from script/rails:6:in `<main>'

After trying a silly solution that didn't work (creating a file named log/production/production.log in the hopes it was just a permissions error where the log couldn't write), I thought about it a little more, then thought: hmm, this slash doesn't look right. So I changed the contents of my Procfile to this:

web: bundle exec rails server thin -p $PORT -e $RAILS_ENV

And sure enough it started working. Hopefully this helps someone else!

You could also change your Procfile to this to get a slightly less verbose output:

web: bundle exec thin start -p $PORT -e $RAILS_ENV
Nicolás Hock Isaza

@fullbridge-batkins I had to remove config.logger = Logger.new(STDOUT) that from the production.rb file. My co-worker added it before cedar to see the params but that was making it fail.

Rohit Joshi

web: bundle exec rails server thin -p $PORT instead of
web: bundle exec rails server thin -p $PORT -e $RACK_ENV/$RAILS_ENV in procfile
worked for me !!! :-)

Ben Atkins

@RohitRox I think you're still going to want your Procfile to read like this:

 web: bundle exec rails server thin -p $PORT -e $RAILS_ENV

So that you can be certain it will be run in production mode.

Rohit Joshi

exactly .. thanks for the quick response. I also noticed that doing -e $RACK_ENV/$RAILS_ENV , it was searching in log/production/production.log which it won't found n
web: bundle exec rails server thin -p $PORT -e $RAILS_ENV fixed that !! cheers !!

Ben Atkins

I believe they meant to specify that you should use $RACK_ENV or $RAILS_ENV but they did a poor job of explaining. They should really have split it up into two lines to clarify.

Donn Felker

For what its worth (to future visitors) I had this same issue but was running Webrick. I included a Profile to use Thin and then deployed. I still had the same error. I removed the Profile and then redeployed and then the error magically went away. Not sure WHY this is happening. Very odd.

Matt Sly

When I switched my Procfile to use Unicorn instead of Thin as the web-server (which Heroku recommends for Cedar) I no longer hit this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.