1

由于找不到 staging.log ,我们的 heroku staging 应用程序在启动时崩溃。这似乎很奇怪,因为它应该只是将所有内容输出到 development.log,所以我不确定发生了什么。

任何帮助将不胜感激!谢谢!

这是堆栈跟踪:

2012-04-18T19:20:36+00:00 heroku[web.1]: State changed from crashed to created
2012-04-18T19:20:36+00:00 heroku[web.1]: State changed from created to starting
2012-04-18T19:20:37+00:00 heroku[slugc]: Slug compilation finished
2012-04-18T19:20:40+00:00 heroku[web.1]: Starting process with command `bundle exec rails server -p 49887`
2012-04-18T19:20:46+00:00 app[web.1]: => Booting WEBrick
2012-04-18T19:20:46+00:00 app[web.1]: => Rails 3.0.3 application starting in staging on http://0.0.0.0:49887
2012-04-18T19:20:46+00:00 app[web.1]: => Call with -d to detach
2012-04-18T19:20:46+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-04-18T19:20:46+00:00 app[web.1]: Exiting
2012-04-18T19:20:46+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:8:in `size': No such file or directory - log/staging.log (Errno::ENOENT)
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/rack/log_tailer.rb:8:in `initialize'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:247:in `new'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:247:in `block in build_app'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:243:in `reverse_each'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:243:in `build_app'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:253:in `wrapped_app'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.5/lib/rack/server.rb:204:in `start'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
2012-04-18T19:20:46+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
2012-04-18T19:20:46+00:00 app[web.1]:   from script/rails:6:in `require'
2012-04-18T19:20:46+00:00 app[web.1]:   from script/rails:6:in `<main>'
2012-04-18T19:20:47+00:00 heroku[web.1]: Process exited with status 1
2012-04-18T19:20:47+00:00 heroku[web.1]: State changed from starting to crashed
4

3 回答 3

2

您的应用程序应该将其日志输出到 STDOUT,而不是服务器上的文件。有关详细信息,请参阅开发中心上的日志记录文章:https ://devcenter.heroku.com/articles/logging

Heroku 在部署时自动将rails_log_stdout注入到您的应用程序中,这修复了 Rails 默认日志记录,所以我不确定为什么这里没有发生这种情况。当您部署到 Heroku 时,您是否看到以下行输出?

-----> Rails plugin injection
   Injecting rails_log_stdout
   Injecting rails3_serve_static_assets
于 2012-04-18T20:24:49.983 回答
1

如果您有 config/environments/staging.rb 文件,请确保您已将 RACK_ENV 和 RAILS_ENV 都设置为“staging”。

heroku config:add RACK_ENV=staging --app myapp-staging
heroku config:add RAILS_ENV=staging --app myapp-staging
于 2012-05-22T04:21:06.943 回答
0

您是否有一个Procfile来指定您要运行的环境?我不相信 Heroku 要求这样做,但它允许您指定环境等。

于 2012-04-18T20:10:52.353 回答