Rubber not starting rails server - ruby-on-rails

I used complete_passenger_mysql recipe and successfully deployed the app.
Last command I saw was, '* 2013-11-10 03:36:59 executingcleanup''`, and then it automatically ended the session, without any error.
So, I guess, deployment was successful.
Now, when I try to browse my app, it just lists files/directories of my app's public directory ( 404.html, 422.html, 500.html , assets folder etc.)
So, I think apache is working fine. But rails server is not live. Do I need to do anything special for that ? I just did cap deploy to deploy the app.

please check the log file on server
deployed_path/current/log/production.log
or you can try this in console of the server
$ RAILS_ENV=production rails c
The db config will make issue if it's wrong.
config/database.yml

Related

Rails server not working when copying back from staging deploy

I ssh copied a rails app from a staging server because the development repository has been lost. My goal is to create a new development code base using the deployed code as a source. So far I have removed a hidden .bundle folder and replaces several aliases with folders and files. I then ran bundle install. For the database I did a sql dump from staging and used it to build a development database. I think I'm ready to run rails server. But when I try to run rails server in the base directory. It gives me the rails command line help as if I was running rails s in a directory with no app.
I'm not even sure if it is possible to reverse a deploy this way. I've looked at the rails guide on the app initialization process and all the files seem to be in place.
Remember that for Rails to start up, you need bin/rails, bin/bundle, config/boot, etc.
If you restore those files, it should work again.

rails 4.2 capistrano 3 Ubuntu nginx puma, getting routing error/no assets shows up

After following this tutorial, I tried was able to set up a rails application on an ec2 Ubuntu instance, running nginx web server and puma app server, deployed with capistrano 3. However, none of my assets are showing up, and I'm getting routing errors for basic functions of the Devise gem such as logging out. The chrome dev tool console shows 404 errors for the compiled application.css and application.js files.
I think the assets are there because if I ssh into the instance and go to the folder where my app is, I can see a bunch of files under public/assets. Also, if I check the capistrano logs, I can find the line bundle exec rake assets:precompile, and the status for that is successful. I tried things like going into the production.rb file and changing config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? to config.serve_static_files = true
but still no assets. I think the biggest suspect is that there is some sort of routing error, because I don't really understand how web servers, app servers, and aws instances interact with each other. Could anyone point me in the right direction on debugging this? If you need to see a specific config file please comment below.
Ok it turns out all I had to do is copy the secrets.yml from the local repo for my app to the shared folder that is in [my_app_name]/shared/config. So my app didn't know where to look for the secret key base.
Although I'm still confused on why not having the secret.yml would prevent assets from served...

"Incomplete response received from application" from nginx / passenger

I tried to deploy my rails app on nginx and ubuntu via capistrano like the tutorial on the page https://gorails.com/deploy/ubuntu/14.04.
but at the end i get an error message:
Incomplete response received from application
in my browser.
this is probably an error from passenger, but how can i figure out what to do?
Your rails_env production don't have required set up,probably missing secret_key_base.
Open /etc/nginx/sites-available/default and change the rails_env to development:
rails_env production;
to
rails_env development;
If the app is loading it's not a passenger issue.
Production Solution:
Enter your app root
run: rake secret
copy the output
go to /yourapp/config/secrets.yml
set the production secret_key_base
Restart the passenger app :
touch /yourapp/tmp/restart.txt
This error occurs because you didn't set the secret_key_base. Follow these steps to fix it:
Go to your rails app directory
cd /path/rails-app
Generate secret key base
rake secret RAILS_ENV=production
Set environment variable
SECRET_KEY_BASE=<the-secret-key-base>
Restart the Rails app
touch /path/rails-app/tmp/restart.txt
I had this problem over the weekend (it turned out there was an incompatibility between my versions of passenger and ruby).
However, nobody seems to be mentioning: the actual error might appear in /var/log/apache2/errors.log, not in any custom log.
Once you know that, hopefully your search will be easier!
Update, since I needed to refer back to this again - this hold true for nginx too - /var/log/nginx/error.log is your friend in that case!
For those using Passenger:
• Navigate to root of your project.
• run bundle exec rake secret RAILS_ENV=production
• Copy the output and then run sudo nano config/secrets.yml
• Under production, replace the value of the secret_key_base with the recently copied rake secret.
• press CNTRL+X, then press y, then hit enter.
• run passenger-config restart-app and select the app you wish to restart.
https://www.phusionpassenger.com/library/admin/apache/restart_app.html
In my case, it was because my server was running out of RAM intermittently (during PDF generation). Once the PDF was generated, some RAM was restored and the error would disappear.
I had an ubuntu server with 500M of RAM.
I added some swap space and this error disappeared.
Might be my answer is off topic, but when my database mysql server isn't running, i got this error too. Just in case someone has the same error.
so start/restart your database might be another answer.
This means that your rails app tanked before actually getting to rails itself. This could be an exception in middleware, missing ENV key, something at the OS level.
Try booting the app locally first and doing what you did to get the error in production. If everything is fine, check all of your logs. Check nginx logs, your passenger logs, and finally any other OS specific logs pertaining to booting and running your app.
Is there anybody like me who got this error after uploading a file?
My solution is check the name of the file which may has some special characters like `[(~.
Just remove it then upload the file again.
Good luck~
I got this, only on my test server and not in production, because I was requesting a URL that didn't exist, and I guess in the test environment, Rails throws an error instead of returning a 404 response.

Capistrano 3 SSHKit::Runner::ExecuteError: Exception while executing on host [hostname ]agent could not sign data with requested identity

I'm getting the following error while deploying my rails app to an ubuntu server, I have correctly setup ssh keys and I can ssh to the server but I'm getting the following when I try to do
cap production deploy
This is the error message
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxxxxx.xxxxxxx.xxx: agent could not sign data with requested identity
I can't figure out what I am doing wrong since I had previously deployed and I just need to update my app to changes I have made. I have not changed my deploy.rb, Capfile or deploy/production.rb files since I last deployed
I solved a similar issue by just issuing ssh-add. It seems that my current environment hasn't properly picked up the keys and readding them fixed the issue.
I had the same error.
ssh-copy-id user#ipaddress
Helped me to solve this.
I had the same issue but in my case I had to delete file .ssh/known_hosts from my local machine.
After upgrading Rails from 4.1.x to 4.2, I started getting similar errors when trying to bundle. I fixed it by removing the shared bundle directory. Here's the steps I took:
SHH into the server
cd /my/app/shared/bundle/ruby
rm -rf 2.1.0 or whatever "version" directory is there
Re run the deploy cap production deploy
You may, at this point, hit a memory snag (I did while deploying to a DigitalOcean droplet). The fix for that is to create and enable a swap file on the droplet.

rails app - sudden 403 after pull - how do I start to debug?

I'm been working on a rails 3.1 app with one other dev.
I've just pulled some of his recent changes, using git. And am now getting a 403 on any page I try to visit.
You don't have permission to access / on this server.
I'm running the site locally through passenger.
Oddly, when I start the app using rails' internal server. I can visit the site at http://0.0.0.0:3000
Looking at the changes in this recent pull, the only files have changed are some javascripts, some html the application.rb, routes.rb and a rake file.
How do I debug this, I'm a bit lost on where to start?
EDIT:
If I roll back to an earlier version the site works, through passenger. Which leads me to believe the problem is within the rails app, rather than an Apache error. Or it could be a permissions thing, can git change file permissions in this way?
IMHO this is a configuration error in Apache or wrong directory layouts. Make sure that the passenger_base_uri still points to the public folder inside your rails project and that there are no hidden .htaccess files which block access. Also verify that your sym-links are correct (if there are any). Also check your Apache error log.
Start by launching your console to see if rails and your app can be loaded.
In your application root directory type :
rails console

Resources