Reputation: 6761
I have been assigned to find a bug in the dashboard of our (production) order management app. It shows wrong data. As I don't have that particular data locally, and can't get it soon, I will have to do it in the production app.
I have never worked with or in an app that is running live before and have no idea about best practices, no-gos, security precautions etc.
If someone could provide some clues to where to start reading (Software, Tools, Tutorials, ...) that would help me a lot. For some reason I only find info on how to prepare for and deploy Rails apps. But not about how to actually manage a running app (that has been deployed by someone else).
An example: As I needed to compare the stats with the real data, I wanted to run a console (rails console --sandbox
) and have a look around, fire some queries. I tried:
www/project-name/current
)rails console production
But that last command gives me:
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
So I guess I am not supposed to do that. How would I investigate such an error then? Querying the database directly seems dangerous.
Any tips? THX!
Upvotes: 4
Views: 4618
Reputation: 620
As written by @ahmed-samir-shahin you need to use bundler to fetch the current ruby environment. When I have to debug production errors in my projects I typically use a command like
RAILS_ENV=production bundle exec rails console
I tend to use the ENV
var instead of the rails console <env>
notation.
As you are pointing out the error occurs on some dashboard. I assume that you are only reading data from your database there. If so I then use the code involved (most likely code from the controller action) for trying to debug the behaviour.
By running the code in the console you can narrow down to point where things are getting messed up. This is what I normally do when there is some kind of urgency involved and ONLY when you are just reading data from the database.
BUT you should try to get someone to make the data available in a staging environment where it is safe to play around with the data.
After figuring out why the problem occurs start setting up a test case on your local machine and fix the problem. :)
Alternative
Run the code / queries in the rails console. Store the results (copy and paste) and reuse the data to create a test case which you can then debug on your local machine.
General advice - ask your boss for a strategy
In general you should talk about this with your manager how to deal with these kind of situations. It is important to everyone in the team how to tackle problems in production systems. I think someone should be responsible for this kind of emergencies. Also some more experienced people in your company should help / assist you while you make your first steps in debugging production issues.
I think it's in the company's best interest to train you in that field. Imho your company has to provide some tools to make it easy to dive into the problem. Otherwise such debugging sessions take forever. Anyway no idea how your company is structured :)
Upvotes: 5