Rails + Nginx + Unicorn is trying to build a production environment on Amazon Linux.
If you configure each of these settings and access the server from a browser, nothing will be displayed.
When I checked
unicorn.stderr.log, I found that
secret_key_base was not configured as shown below.
E, [2016-02-26T 11:48:42.067474#11474] ERROR --:app error:Missing `secret_token` and `secret_key_base` for 'production' environment, set these values in `config/secret.yml` (RuntimeError) E, [2016-02-26T11:48:42.067574#11474] ERROR -- :/home/ec2-user/rails_test/vendor/bundle/ruby/2.2.0/gems/rails-4.2.3/lib/rails/application.rb:534:in`validate_secret_key_config!' E, [2016-02-26T11:48:42.067602#11474] ERROR -- :/home/ec2-user/rails_test/vendor/bundle/ruby/2.2.0/gems/rails-4.2.3/lib/rails/application.rb:246:in`env_config' The following...
However, SECRET_KEY_BASE is configured on the command line as follows:
SECRET_KEY_BASE=Long random string
You can also verify that the environment variable is set in
bundle exec rails -b 0.0.0.0-e production can access the URL where the error occurred without any problems.
The secret_key_base of the production remains the default as shown below.
Unicorn and Nginx start as follows:
Unicorn starts with the command
sudo bundle exec unicorn-c config/unicorn.rb-E production-D and
Nginx is started with
sudo service nginx start.
Both have confirmed that the process has started.
Amazon Linux Rails 4.2.3
I entered the secret_key_base for production directly into
config/secret.yml and it was successfully accessed.It seems to be a problem on the Unicorn side.
Please let me know if you know how to avoid entering secret_key_base in
It seems that uincorn is not able to recognize the environment variables properly, but when I fell in love with the same case in the past, it was as follows:
Because defining environment variables directly depends on the linux settings as described above, I use dotenv to define environment variables for rails in the
.env file and load them every time Capistrano deploys them.For your information.
372 Update Flask User Information
342 Memory layouts learned in theory don't work out as expected when actually printed as addresses.
356 Unity Virtual Stick Does Not Return to Center When You Release Your Finger
341 Understanding the Meaning of mpm prefork Settings
340 Scrap text information after the "View More" button when searching in the Yahoo! News search window
© 2023 OneMinuteCode. All rights reserved.