Rails API Using Gem PUMA Development Environment >> Production

Asked

Viewed 120 times

-2

I have developed an API that connects in an oracle database is working properly in development, but when I try to run the GEM Puma in production, it gives error. command to execute

*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 4.3.1 (ruby 2.6.5-p114), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: production
! Unable to load application: ArgumentError: Missing `secret_key_base` for 'prod
uction' environment, set this string with `rails credentials:edit

Erro :
````80:in `validate_secret_key_base': Missing `secret_key_base` for 'production' env
ironment, set this string with `rails credentials:edit` (ArgumentError)´´´´

puma.rb
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count

port        ENV.fetch("PORT") { 3000 }
rails_env = ENV['RAILS_ENV'] || "production"
environment rails_env
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
plugin :tmp_restart

With this I can’t start my application in Production only in DEV

2 answers

2


This error occurs when the system does not meet its definition of secret_key_base, which is important for encrypting cookies, section keys and etc...

Apparently there is some problem with your credential definitions. As shown in ror’s guide, in version 5.2 the encrypted file is created config/credentials.yml.enc to store sensitive information from your application.

Two things may be happening:

  • Missing the file config/master.key, responsible for decoding your credentials in a production environment;

    Obs: It’s common to forget to upload this file to production, since it’s not good practice to send it to git repositories

  • Missing the definition of secret_key_base, or have some error in its specification, because the development environment, depending on its configuration, may not be as strict as the existence of this definition.

Here is a tutorial that can help you through this process: Rails 5.2: Encrypted Credentials (The New Secrets)

0

I managed to solve my Puma problem in production as follows

Run command and copy generated key secret rake Create a file named Secrets.yml in config and copy the generated key in the following format

Production: secret_key_base: 7004d57f202ac9dcdeee45...

Rails s Puma -b IP -e Production

Browser other questions tagged

You are not signed in. Login or sign up in order to post.