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
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?
I made new project with Rails and Vue using webpacker. Firstly I got strange error
Cannot read property 'compile' of undefined
So I hit yarn upgrade webpack-dev-server --latest which was the correct answer and helped me but then when I hit: ./bin/webpack-dev-server my webpack dev server starts and all looks fine but at http://localhost:3035/ I am getting the "Cannot GET /" message.
JS console: Failed to load resource: the server responded with a status of 404
I also tried to reinstall webpacker...
When running your Rails application locally you'll need to start both the rails server and the webpack-dev-server. I typically use foreman with a simple Procfile, although you can also start both of these by hand.
# Procfile
server: bin/rails server
assets: bin/webpack-dev-server
Then you can run the Procfile and startup both servers with: foreman start
The webpack-dev-server port (3035) is not the port you'll be connecting to for seeing your application. Start up both servers and go to localhost:3000 and you'll see your rails application root path page (or default rails page if you dont have routes yet).
One thing to note, if you're using Foreman to start your servers it will default your rails port to 5000 instead of 3000. You can configure this either in the Procfile or when you call foreman if you want different behavior.
I am trying to configure Sidekiq in a Rails 4.1.4 application that connects to an AWS Elasticache Node running Redis.
I set up my Redis server, and followed the directions in this AWS Guide:
http://docs.aws.amazon.com/opsworks/latest/userguide/other-services-redis-cluster.html
And my Redis server was running properly and my app server could connect properly.
I followed these directions to set up Sidekiq to run on the external worker:
https://github.com/mperham/sidekiq/wiki/Advanced-Options
Whenever I visited my app server at the /sidekiq url to view the Sidekiq panel, I kept getting the error on screen saying "Internal Server Error".
My Unicorn error logs do not contain any relevant information, so I am not sure how to get this working. AWS support did not have any answers either.
Any information would be greatly appreciated. Thanks!
This problem is normally seen when assets are not compiled or are not configured to be served from your environment. Start your app/sidekiq in production mode (or whatever environment this is referring to) after changing the production config to point to your local resources (redis+db) and see if the pages are able to load then.
RAILS_ENV=production bundle exec unicorn
RAILS_ENV=production bundle exec sidekiq -c config/sidekiq.yml
I am running a Rails 4 app on a VPS with Ubuntu, NginX and Unicorn.
When I SSL into my server and update the app via git or run rake tasks on the database, my app always switches to development mode and I can't get it into production mode.
Typing RAILS_ENV=production seems to have no effect at all.
When I do
$ rails console
$ Rails.env
I get
--> development
all the time.
What must I do to force NginX into production mode?
Actually, I don't want Nginx to ever run in development mode.
How can this be achieved?
Thanks for any help.
Your application is probably running in production mode by default. What you're doing is engaging a shell, something using a different environment.
Normally on a production server you'd put this into your profile script:
# Add to ~/.bash_profile
export RAILS_ENV=production
That way when you power up rails c you will get the correct environment.
As a note, the only way this shell is engaging in the first place is that you have a development setting in your config/database.yml. That shouldn't be there, as the configuration for your production server should be production-only.
nginx doesn't run in development or production mode - your app does, via your unicorn configuration and/or the RAILS_ENV environment variable when you launch your unicorn instances.
You should be launching your unicorn instances with the RAILS_ENV variable prefixed to the command, eg:
RAILS_ENV=production bundle exec unicorn -c config/unicorn.rb -D
rails console launches a completely different instance which may be in an different environment - it is unrelated to your unicorn instances. If you want to launch a production console instance, then either invoke RAILS_ENV=production rails console or rails console production. Note that this has no bearing on the environment that your application runs in.
I am using private_pub gem for live chat in my rails 3.2 application and it is working perfectly on development mode but I am stuck at how to do it on production.
I am using apache2 in production. When I ran this command on server
RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production
It starts the thin server but my app keeps on waiting for response from
http://www.example.com:9292/faye.js
It doesn't do anything. I am unable to connect with faye in prodution
Thanks for help in advance
Thin and Apache need to be set up running on different ports.
The default settings for both should work, but you should double
check. Ensure apache is running under port 80 and thin is using port
9292. These numbers should be visible when the servers start up.
In the end you should be able to access faye.js at
http://yoursite.com:9292/faye.js and your site at http://yoursite.com/
Source: https://stackoverflow.com/a/6667347/539075