Heroku: get error stack when an error is happening - debugging

Is there any chance we can modify Heroku's behaviour to get the error stack like I have in local?
Ex:
NameError in Best#search
Showing /media/augustin/Documents/Workspace/best/app/views/layouts/application.html.haml where line #29 raised:
undefined local variable or method `new_user_session_pat' for #<#<Class:0x00000002eb09b8>:0x00000004a12008>
Instead of:
We're sorry, but something went wrong.
I know there are heroku logs, I know its certainly not recommended in production environment, but since I'm still developping, I'd be happy to have nicer messages than the logs ones.
Thanks

You can use heroku logs:
$ heroku logs --app your_heroku_app_name
references: http://devcenter.heroku.com/articles/logging

Long time no talk, but the answer was actually very easy :
In /config/environments/env_name.rb (eg. production or staging), you need to set:
config.consider_all_requests_local = true
Besides, it could also be interesting to intercept the error message in production, not to display heroku's default page. It could be done like this :
http://blog.yangtheman.com/2012/10/11/user-friendly-500-and-404-pages-on-rails-3/

Related

Deploying laravel app on Fortrabbit - 403 internal server serror

I followed the setup to deploy laravel app on fortrabbit but now I am stuck with this error:
Error 403
Internal server error
Overload: More requests than the App can handle.
A script stops with an error. Are your config files up to date? Maybe turn on debugging to trace the error.
There is an error in the .htaccess file.
Something else. Please check the fortrabbit status.
I have checked the configurations but I keep find a cause for that or even a solution for this issue.
That's not really a good question to post her on StackOverflow. It's too specific - probably App- or even service-related. For such cases: please try customer support.

failing to enable user-env-compile on Heroku

it is the first time I ask for something so sorry if I'm not enough precise!
I tried to upload my rails app on heroku using enabling the user-env-compile to manage my secret keys but I have an error "No such feature: user-env-compile".
I checked on Heroku devcenter and seems that user-env-compile has been deprecated and replaced by the ENV_DIR argument.
Here the link:
https://devcenter.heroku.com/articles/labs-user-env-compile
I cant really get what to do! can someone explain better to me what I'm supposed to do?
thank you,
Federico
You don't have to do anything (the labs is deprecated and you should delete it), by default now heroku is exporting your environement variables during slug compilation.
Be careful, it is not recommended to use the environement variable during slug compilation (you can check http://12factor.net/ for more informations)
Hope it helps.

Heroku: Force Error Backtrace To Display In Development Mode

I am running a sinatra application on Heroku, and I'm seeing the generic error page:
Stuff I've Tried So Far
heroku logs returns a generic "H10 - Application Crashed" error, which doesn't tell me what the actual cause is.
I've used heroku config vars to set RACK_ENV=development and verified that it is set that way using heroku config. I thought this would force a backtrace to be displayed on the screen but it does not.
Questions
How can I force a backtrace to be displayed in dev mode?
What else can I do to track down the source of this error?
I got a response from Heroku support about this.
Everything I did was correct, the problem is the application boot errors won't display to the screen, and this was a boot error. The source of the error was further back in the backtrace in heroku logs, so that was in fact the right place to look in this case, I just missed it.
Setting RACK_ENV=development is the correct way to display application runtime errors to the screen, according to support.

Twitter handler (sensu and ruby) troubleshooting

I'm trying to get Sensu twitter-handler working on my environment. The issue is that I'm not getting any errors on screen or logs when I cat a .json event into the twitter-handler and, the tweets are not being shown on the linked account.
Here're are my config files:
https://gist.github.com/Mariano-gon/8648427
https://gist.github.com/Mariano-gon/8648455
https://gist.github.com/Mariano-gon/8648489
This is the output I get:
https://gist.github.com/Mariano-gon/8648480
One important note is that in sensu-api.log the request are being recieved:
https://gist.github.com/Mariano-gon/8673758
So, my question is: is there a way to troubleshoot this issue? Any way to debug the handler.rb?
Thanks!
Finally got it working! Thing was the new 'twitter' gem (in my case v5.6) won't work with the code as it was written. I needed to follow this great answer and this thread too. Was just a matter of sintaxis (as usual).
Thanks!

Sinatra - how do I debug it when it's online?

I wrote a teeny tiny Sinatra app that runs fine, locally, but for some reason as soon as I put it online, all I get is 'Internal Server Error'.
How do I get the logging output?
I'm running on Dreamhost with passenger, using the instructions from the Sinatra book.
So I added to more handlers:
get '/hello/:name' do
"Hello, #{params[:name]}!"
end
get '/nokogiri-test/' do
doc = Nokogiri::HTML(open('http://www.google.co.il/search?q='+params[:query]))
res = ''
doc.xpath('//li//h3//a').each do |li|
res+= li.content + '<br />'
end
res
end
The first one works fine, the second throws an error.
I'm not interested in why there's an error. I'm interested in how to get feedback for it and resolve errors in the future.
Ah! The answer comes from here.
Never would have thought to look in there, but I got desperate. The solution is to set the environment to :development:
set :environment, :development
I stuck that into my configuration files and it produced all the error output.
Still doesn't solve my problem if I ever want to discover what's causing an error in a PRODUCTION app...
So how would I solve that?
If you're seeing apache's Internal Server Error message, you should be able to check the apache error log to find out what's going on. I think on dreamhost the log file is stored in /home/your_user_name/logs/yourdomain.com/http/error.log

Resources