Recently I upgraded my Rails app from 4.2 to 5.2.
Since I tried 'cap deploy production',
"activerecord::connectionnotestablished, no connection Pool with 'primary' found" is being returned.
The prod db adapter is mysql2. Postgres is the development adapter
Related
I have an app built with Ruby on Rails version 7.0.2, and I want to deploy it to a VPS using Capistrano Gem, however when it is about to reach near the end of deployment, I get this error: "ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `bin/rails credentials:edit"
When I try to run, EDITOR="code --wait" bin/rails credentials:edit and I enter a secret base key, I push it to github repo, then try to deploy, I still get the same error.
How can I solve this if anyone knows the solution?
Hello I just ran heroku run rails c and heroku ran it on ⬢ immense-spire-28000 which is my staging database not infinite-38185. Any ideas how my production application got connected to my staging database and how I can switch it back?
This is my spec for deployment to my staging:
Rails 4.2.5
Capistrano 3.4.1
Thin 1.7.0
Nginx 1.4.6
Everything works fine, capistrano also able to deploy and run the server
BUT
When I try to access the staging, it's always internal server error and written on log/thin.log on the rails app:
Unexpected error while processing request: Missing 'secret_token' and
'secret_key_base' for 'production' environment, set these values in
'config/secrets.yml'
I also have set the secret_key_base for production environment generated from rake secret RAILS_ENV=production
if I kill the running server process run by capistrano and manually run the server using bundle exec thin -p [MY_PORT] -e production -d start, the error disappears and everything is normal
So,
it passes nginx so the error must be in thin or capistrano
it bugs me everytime I deploy to production then I must kill the
server process and start it manually
my questions are:
why thin server started by capistrano always have error with missing
secret_key_base and secret_token although I already have it on
my secrets.yml?
how to fix it? I'm out of options
Using capistrano I'm deploying my Rails 4 app under the environment name "staging". When I ssh onto the server and run rails console, any ActiveRecord queries I do come up with no such table. So I check my Rails.env and sure enough it reads development instead of staging. But even running rails console staging, it does set Rails.env to "staging", but still the ActiveRecord queries say no such table. The app itself is running fine (under Apache and Passenger), but for some reason the rails console is unable to connect to the db.
I've reverted back to when I knew it was working and am still seeing the error, which tells me it is a configuration change i must've made on the server as opposed to a change to the rails app code or capistrano deploy config.
OK, tracked down the answer myself. The RAILS_ENV was originally being set to staging in /etc/environment -- but a while ago this file was removed during some debugging, and not restored.
What does still surprise me is that
rails console staging
does not have the same effect as
export RAILS_ENV=staging
rails console
anyhow, sorted.
I have successfully installed and configured apache with passenger for deploying a rails application. I installed the 'mysql' and 'rails' gems successfully, but when I run any rake commands like
rake db:create
to create the database, I get this error
Illegal instruction
Any idea why?