New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nhocki opened this Issue Sep 25, 2011 · 15 comments

Comments

Projects
None yet
9 participants
@nhocki

nhocki commented Sep 25, 2011

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

@nhocki

This comment has been minimized.

Show comment
Hide comment
@nhocki

nhocki Sep 29, 2011

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

nhocki commented Sep 29, 2011

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

@joeferraro

This comment has been minimized.

Show comment
Hide comment
@joeferraro

joeferraro Oct 8, 2011

having the same issue...

joeferraro commented Oct 8, 2011

having the same issue...

@nhocki

This comment has been minimized.

Show comment
Hide comment
@nhocki

nhocki Oct 8, 2011

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

nhocki commented Oct 8, 2011

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

@rtekie

This comment has been minimized.

Show comment
Hide comment
@rtekie

rtekie Oct 25, 2011

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.

rtekie commented Oct 25, 2011

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

This comment has been minimized.

Show comment
Hide comment
@georgegwu

georgegwu Jan 31, 2012

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,

georgegwu commented Jan 31, 2012

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,

@RohitRox

This comment has been minimized.

Show comment
Hide comment
@RohitRox

RohitRox Mar 4, 2012

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 !!

RohitRox commented Mar 4, 2012

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 !!

@batter

This comment has been minimized.

Show comment
Hide comment
@batter

batter Mar 7, 2012

@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

batter commented Mar 7, 2012

@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
@nhocki

This comment has been minimized.

Show comment
Hide comment
@nhocki

nhocki Mar 7, 2012

@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.

nhocki commented Mar 7, 2012

@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.

@RohitRox

This comment has been minimized.

Show comment
Hide comment
@RohitRox

RohitRox Mar 8, 2012

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 !!! :-)

RohitRox commented Mar 8, 2012

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 !!! :-)

@batter

This comment has been minimized.

Show comment
Hide comment
@batter

batter Mar 8, 2012

@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.

batter commented Mar 8, 2012

@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.

@RohitRox

This comment has been minimized.

Show comment
Hide comment
@RohitRox

RohitRox Mar 9, 2012

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 !!

RohitRox commented Mar 9, 2012

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 !!

@batter

This comment has been minimized.

Show comment
Hide comment
@batter

batter Mar 9, 2012

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.

batter commented Mar 9, 2012

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.

@donnfelker

This comment has been minimized.

Show comment
Hide comment
@donnfelker

donnfelker Dec 25, 2012

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.

donnfelker commented Dec 25, 2012

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.

@mattsly

This comment has been minimized.

Show comment
Hide comment
@mattsly

mattsly Apr 17, 2013

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

mattsly commented Apr 17, 2013

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

@ddollar

This comment has been minimized.

Show comment
Hide comment
@ddollar

ddollar Nov 7, 2014

Owner

Hello. I apologize for the delayed response. I am currently declaring issue bankruptcy. If this issue still applies to you please feel free to re-open and explain. Thanks :)

Owner

ddollar commented Nov 7, 2014

Hello. I apologize for the delayed response. I am currently declaring issue bankruptcy. If this issue still applies to you please feel free to re-open and explain. Thanks :)

@ddollar ddollar closed this Nov 7, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment