[RAILS] Deployment error

I will write it down as a memorandum. Edit as needed.

If Capistrano works

With the following settings, the error message will be displayed in the browser in the production environment as well as in the local development environment.

config/environments/production.rb

(Omitted)
  config.consider_all_requests_local = true
(Omitted)

Find the above description in the "config/environments/production.rb" file. Originally it is "false", so change it to "true".

We need to reflect this change in the production environment, so do the following two operations. ① Push to GitHub ② Execute "bundle exec cap production deploy"

When you have finished handling the error, don't forget to set it back to false and redeploy.

* Since the error message can be confirmed from the outside, information that should not be known for security may be leaked.

If Capistrano fails

If Capistrano gives an error, you can't do the above. Let's check the error log directly.

Depending on the nature of the error, the logs are mainly written to the following two files. If you're not sure which one applies to you, check both.

How to check Unicorn error log

Terminal

cat /var/www/(app name)/current/log/unicorn.stderr.log 

Terminal

cat /var/www/(app name)/current/log/production.log

At first, reading the error log is a bit difficult, so here are some points. please refer.

How to check the error log of Rails app When checking the error log, be aware of the following points

How to read the error log ・ The lower the file, the newer the log. ・ Be sure to check when the log is

It is important to see when the log is for the error that occurred.

First, if there is a time stamp in the log, add 9 hours to it (the output is in standard time, so there is a time difference of 9 hours in Japan). Compare that time with the current time to check if the error has just occurred.

If there is no error display even after checking the log

It may be a rare case, but if you check the log and there is no error

rm current/log/unicorn.stderr.log

After deleting the log history with ↑

less current/log/unicorn.stderr.log

It may be displayed if you confirm with ↑.

Recommended Posts

Deployment error
tomcat error
Deployment failed
Eclipse error
Error memorandum
Automate deployment
FindBugs-IDEA error
[Rails] AWS deployment error encounter summary
[Deployment error] Mysql2 :: Error: Table'~' already exists: CREATE TABLE `~`
bundle install error
Today's java error
MySql connection error
ITMS-90626 Error Resolution
bundle install error
java error countermeasures
[Swift] Error handling
CodingKeys non-decodable error
Maven3 error memo
composer install error
Uninitialized constant ~~ error