Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy Ubuntu 14.04 Trusty Tahr Discussion

Chris Oliver asked in General
Chirag Nayyar Chirag Nayyar

Hi i am unable to run my rails application in production mode. I am using AWS EC2 and in development mode it is working fine but in production mode it give me error "Incomplete response received from application" I searched it on google but didn't find any proper solution yet.

Anyone here to help me?

Reply

Hey Chirag, I might be able to help. We rescheduled on HackHands a few hours ago. Let's see what you currently have; from there I can suggest what to do. hackhands.com/oreoluwa

Reply

Make sure that your secrets.yml is populated with proper value of secret_key_base. I was facing the same issue and once I set the correct value of secret_key_base, error went away.

Reply

Hello,
Chris for thirst, thx for that great article. It would be
great if you write few words about scalling up application into many
passenger workers. I couldn't find any good and easy to understand
tutorial how to do that on custom vps instance.

Reply

Yeah! I will do that. Generally with an individual server you want to set the number of workers equal to the number of CPUs on your VPS. Digital Ocean will show you how many CPUs you have on your machine in their dashboard and you can configure that workers variable and restart nginx to make that work.

I'll make a video on this in the future!

Reply
Boris Tkachev Boris Tkachev

does anybody received this error when refreshing server?
Incomplete response received from application

Reply

Hmm, I've had this a few times before. I think typically it is caused by an error in your application. Check your nginx and rails log files to see if you find any errors listed.

Reply
Magzhan Shokparbayev Magzhan Shokparbayev

GREAT Tutorial ! I set this up with couple of hours.

Reply
Nikita Melnikov Nikita Melnikov

Hello @excid3:disqus ! Thanx for tutorial! I faced with problem that I trying to solve at least 4 hours..
When I create user for Postgres it returns me the next error:

createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

It seems that postgres was installed properly

[sudo] password for deploy:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpq-dev is already the newest version.
postgresql is already the newest version.
postgresql-contrib is already the newest version.

Command ps auxwww | grep postgres shows the below

deploy 1869 0.0 0.1 13456 956 pts/1 S+ 09:16 0:00 grep --color=auto postgres

How can I fix this problem? I've already tired googling..

Reply
Nikita Melnikov Nikita Melnikov

It seems that I've resolved issue..
The problem was with locale.

If someone face with that problem you should uninstall postgres and reconfigure your locale.

sudo locale-gen ru_RU.UTF-8

sudo dpkg-reconfigure locales

Reply

There's a section of the article that says: "For the rest of this tutorial, make sure you are logged in as the deploy user on the server!"

However, starting at the section named "Capistrano Setup", you actually supposed to be on your local computer (NOT the the remote server).

Reply

@excid3:disqus this was confusing for me as well. MIght need to add another alert box to say when you should jump back to your local machine.

Reply

With Rails 4.2.2 (rvm) I also needed to install

sudo apt-get install libgmp-dev

in order to install 'pg' gem

Reply
Michael Trojanek Michael Trojanek

Even though I have to admit that I haven't watched the full video, this seems to be a great resource for a lot of people to learn how to deploy your Rails application on a production server – so first of all, big thanks for publishing it and helping a lot of Rails developers!

However, judging from the comments, quite some people seem to have their problems in getting everything to work.

I do not know if this will be considered a shameless plug but since my whole business is about running Rails applications in production, I want to point everyone who has made it through this tutorial to https://efficientrailsdevop... – a book about managing your Rails environment with Ansible. It will be of great value if you are looking for a more controlled and reproducible approach to provisioning and deployment.

Reply
Rory O'Keeffe Rory O'Keeffe

Wow. Just want to chime in and say holy crap that is some well-written copy. Actually felt my heart starting to beat faster reading it! Once I'm ready to deploy, you'll have another customer for sure.

Reply

Great tutorial ! But :
What if I'd like to deploy a second rails app to my vps ? How should I modify the /etc/nginx/sites-enabled/default file to respond to
mysite.com/app1 and mysite.com/app2 ?

Reply

Exactly. Add a new server block to the nginx config, setup your new database, deploy your other app, and voila! Should be all you need to do.

Reply

How can I setup email smtp production settings after successfully installing this?

Reply

Hi, i'm pretty new to rails and discovered your site with this guide. I followed all the steps until the "cap production deploy" that gave me this error : (cap production deploy --trace) - Im using cloud9 online IDE to follow this guide.

/usr/local/rvm/gems/ruby-2.2.1/gems/capistrano-3.1.0/lib/capistrano/i18n.rb:4: warning: duplicated key at line 6 ignored: :starting
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_linked_dirs (first_time)
** Execute deploy:set_linked_dirs
** Invoke deploy:set_rails_env
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
cap aborted!
NoMethodError: undefined method `on' for main:Object
/usr/local/rvm/gems/ruby-2.2.1/gems/capistrano-rbenv-2.0.4/lib/capistrano/tasks/rbenv.rake:3:in `block (2 levels) in <top (required)="">'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/gems/ruby-2.2.1/gems/capistrano-3.1.0/lib/capistrano/dsl/task_enhancements.rb:12:in `block in after'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.2.1/gems/capistrano-3.1.0/lib/capistrano/application.rb:15:in `run'
/usr/local/rvm/gems/ruby-2.2.1/gems/capistrano-3.1.0/bin/cap:3:in `<top (required)="">'
/usr/local/rvm/gems/ruby-2.2.1/bin/cap:23:in `load'
/usr/local/rvm/gems/ruby-2.2.1/bin/cap:23:in `<main>'
/usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => rbenv:validate

Until the "cap production deploy" all was good. Do you have an idea on what's going on ?
Thanks

Reply

im having same problem!
Did u solve this?

Reply

Should there have been a step in this tutorial to install Rails on the server? Say around the area where Bundler is installed? Or did you pick an image that had Rails included?

Reply

No actually. Since you've got Bundler, Capistrano will run "bundle install" on deploy and will install Rails for you. That's the nice part about it, since you have Rails inside your Gemfile, Capistrano will automatically install it!

Reply

After doing everything right, and destroying almost 10 droplets. I keep getting this error.

We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.

The Phusion Passenger application server encountered an error while starting your web application. Because you are running this web application in staging or production mode, the details of the error have been omitted from this web page for security reasons.

Please read the Passenger log file to find the details of the error.

Alternatively, you can turn on the "friendly error pages" feature (see below), which will make Phusion Passenger show many details about the error right in the browser.

To turn on friendly error pages:

Nginx integration mode

Apache integration mode

Standalone mode

Reply

Thank you for this great walkthrough!

I think the two lines for installing nginx are duplicates.

Reply

To deploy multiple Rails apps to the same server, you will need to replicate the capistrano settings for the second app, create another database, and change the default file in /etc/nginx/sites-enabled like the following:

server {
listen 80;
listen [::]:80 ipv6only=on;

server_name domain1;
passenger_enabled on;
rails_env production;
root /home/deploy/first_app/current/public;

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

server {
listen 80 ;
listen [::]:80;

server_name domain2;
passenger_enabled on;
rails_env production;
root /home/deploy/second_app/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

Hope this helps someone. Many thanks Chris for this tutorial.

Reply

when i run " cap install STAGES=production " command in my local machine i am getting below error
can you please help me

/home/home/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- capistrano/cli (LoadError)
from /home/home/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/bin/cap:3:in `<main>'

it does't create capfile in my app

Reply

when i run " cap install STAGES=production " command in my local machine
i get perfect result

cap install STAGES=production
mkdir -p config/deploy
create config/deploy.rb
create config/deploy/production.rb
mkdir -p lib/capistrano/tasks
create Capfile
Capified

but doesn't create capfile in my application

Reply

the passenger ruby lines in nginx.conf are moved to a file called passenger.conf

Reply
Mike Simonitsch Mike Simonitsch

Man, such a dope walkthrough and Vid. Thank you for this.

Reply

Thanks Mike. Doing my best to keep it updated! :D

Reply

@excid3:disqus I've been deploying on Digital Ocean and works so fine! But Now i had to deploy in other cloud... everything goes ok... but, when i access from browser with ip... i got nothing!

passenger-status: "Phusion Passenger is currently not serving any applications."
nginx status: "nginx is running"

On nginx.conf there is that line: include /etc/nginx/passenger.conf;
And inside de passenger.conf i put:

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deployer/.rbenv/shims/ruby;

in my case, of course... Any ideas?

Reply

Hmm, hard to say. Maybe restart nginx to make sure you got your config for the rails app loaded?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,584+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.