Deploy Ruby On Rails on
Ubuntu 12.04 Precise Pangolin

A guide to setting up a Ruby on Rails production environment



This will take about 45 minutes.

Skip all this work and let Hatch configure your servers and deploy Rails apps to it. Check out Hatch!

We will be setting up a Ruby on Rails production environment on Ubuntu 12.04 LTS Precise Pangolin.

Since we setup Ubuntu for our development environment, we also want to use it in production. This keeps your application running consistently between development and production. We're using an LTS version of Ubuntu in production because it is supported for several years where a normal version of Ubuntu isn't.

Using Ubuntu LTS in production allows you to continue receiving security updates which is important for your production server(s).

We're going to be setting up a Droplet on Digital Ocean for our server. It costs $5/mo and is a great place to host your applications.

If you sign up with my Digital Ocean referral link, you'll get 2 months ($10) free credit to try it out.

You can use any cloud server hosting company you choose for your Rails application. I've had excellent experience with Digital Ocean and Linode with the servers I have used. If you're looking for alternatives outside the US or otherwise, just google "VPS hosting". A VPS is a virtual private server. It's just like a server you setup at home, only virtualize and running with a suite of other servers in a datacenter.

Since we're using Digital Ocean for our cloud server, the first thing we're going to do is configure a new one. I'm going with the Droplet with 1GB of RAM. You can setup whichever size server you prefer, keep in mind that if you choose a 512MB server you may run into some slowness with a low amount of RAM.

Droplet Size

The next step is to choose your location. Choose one close to you so that you can have better connection speeds.

Droplet Region

Last, but not least we need to choose which OS to use. We're going to be using Ubuntu 12.04 LTS x64. Your application may require a different OS or version, but if you're not sure this is generally what you should use.

Droplet Image

Optionally you can add your SSH key into the Droplet so you can SSH in and skip the ssh-copy-id step.

Once Digital Ocean has configured your server, check your email to get your password for the new cloud server.

You should follow the instructions in the email to login via SSH for the very first time and verify it is working.

The first thing we will do on our new server is create the user account we'll be using to run our applications and work from there.

sudo adduser deploy
sudo adduser deploy sudo
su deploy

Before we move forward is that we're going to setup SSH to authenticate via keys instead of having to use a password to login. It's more secure and will save you time in the long run.

We're going to use ssh-copy-id to do this. If you're on OSX you may need to run brew install ssh-copy-id but if you're following this tutorial on Linux desktop, you should already have it.

Once you've got ssh-copy-id installed, run the following and replace IPADDRESS with the one for your server:

Make sure you run ssh-copy-id on your computer, and NOT the server.

ssh-copy-id [email protected]

Now when you run ssh [email protected] you will be logged in automatically. Go ahead and SSH again and verify that it doesn't ask for your password before moving onto the next step.

For the rest of this tutorial, make sure you are logged in as the deploy user on the server!

Choose the version of Ruby you want to install:

The first step is to install some dependencies for Ruby and Rails.

To make sure we have everything necessary for Webpacker support in Rails, we're first going to start by adding the Node.js and Yarn repositories to our system before installing them.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs yarn

Next we're going to be installing Ruby using one of three methods. Each have their own benefits, most people prefer using rbenv these days, but if you're familiar with rvm you can follow those steps as well. I've included instructions for installing from source as well, but in general, you'll want to choose either rbenv or rvm.

Choose one method. Some of these conflict with each other, so choose the one that sounds the most interesting to you, or go with my suggestion, rbenv.

Installing with rbenv is a simple two step process. First you install rbenv, and then ruby-build:

cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

rbenv install 2.5.0
rbenv global 2.5.0
ruby -v

The installation for rvm is pretty simple:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm install 2.5.0
rvm use 2.5.0 --default
ruby -v

Arguably the least useful Ruby setup for development is installing from source, but I thought I'd give you the steps anyways:

cd
wget http://ftp.ruby-lang.org/pub/ruby/2.5/ruby-2.5.0.tar.gz
tar -xzvf ruby-2.5.0.tar.gz
cd ruby-2.5.0/
./configure
make
sudo make install
ruby -v

The last step is to install Bundler

gem install bundler

rbenv users need to run rbenv rehash after installing bundler.

Phusion is the company that develops Passenger and they recently put out an official Ubuntu package that ships with Nginx and Passenger pre-installed.

We'll be using that to setup our production server because it's very easy to setup.

# Install Phusion's PGP key to verify packages
gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
gpg --armor --export 561F9B9CAC40B2F7 | sudo apt-key add -

# Add HTTPS support to APT
sudo apt-get install apt-transport-https

# Add the passenger repository
sudo sh -c "echo 'deb https://oss-binaries.phusionpassenger.com/apt/passenger precise main' >> /etc/apt/sources.list.d/passenger.list"
sudo chown root: /etc/apt/sources.list.d/passenger.list
sudo chmod 600 /etc/apt/sources.list.d/passenger.list
sudo apt-get update

# Install nginx and passenger
sudo apt-get install nginx-full passenger

So now we have Nginx and passenger installed. We can manage the Nginx webserver by using the service command:

sudo service nginx start

Open up the server's IP address in your browser to make sure that nginx is up and running.

The service command also provides some other methods such as restart and stop that allow you to easily restart and stop your webserver.

Next, we need to update the Nginx configuration to point Passenger to the version of Ruby that we're using. You'll want to open up /etc/nginx/nginx.conf in your favorite editor. I like to use vim, so I'd run this command:

sudo vim /etc/nginx/nginx.conf
# You could also use nano if you don't like vim
# sudo nano /etc/nginx/nginx.conf

Find the following lines, and uncomment them:

##
# Phusion Passenger
##
# Uncomment it if you installed ruby-passenger or ruby-passenger-enterprise
##

include /etc/nginx/passenger.conf;

Save and close nginx.conf. Then open /etc/nginx/passenger.conf in your editor to modify the ruby line:

sudo vim /etc/nginx/passenger.conf

# You could also use nano if you don't like vim
# sudo nano /etc/nginx/passenger.conf

And change the passenger_ruby line to point to your ruby executable:

passenger_ruby /home/deploy/.rbenv/shims/ruby; # If you use rbenv
# passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.1.2/ruby; # If use use rvm, be sure to change the version number
# passenger_ruby /usr/bin/ruby; # If you use ruby from source

The passenger_ruby is the important line here. Make sure you only set this once and use the line from the example that pertains to the version of Ruby you installed..

Once you've changed passenger_ruby to use the right version Ruby, you can run sudo service nginx restart to restart Nginx with the new Passenger configuration.

Now that we've restarted Nginx, the Rails application will be served up using the deploy user just how we want. In the Capistrano section we will talk about configuring Nginx to serve up your Rails application.

Setting up your production database is pretty easy. Make sure to keep in mind that you should use a different password for your production databases.

Depending on what database you want to use, follow the steps related to the database:

Installing MySQL

All you need to do in order to install MySQL is to run the following command:

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

You can use the root user and password set during installation for your database or you can add a new user to MySQL.

Installing PostgreSQL

Postgres 9.1 is available in the Ubuntu repositories and we can install it like so:

sudo apt-get install postgresql postgresql-contrib libpq-dev

Next we need to setup our postgres user:

sudo su - postgres
createuser --pwprompt
exit

The password you type in here will be the one to put in your my_app/current/config/database.yml later when you deploy your app for the first time.

The fancy new verison of Capistrano 3.0 just shipped and we're going to be using it to deploy this application.

The first step is to add Capistrano to your Gemfile:

gem 'capistrano', '~> 3.1.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'

# Add this if you're using rbenv
# gem 'capistrano-rbenv', github: "capistrano/rbenv"

# Add this if you're using rvm
# gem 'capistrano-rvm', github: "capistrano/rvm"

Once these are added, run bundle --binstubs and then cap install STAGES=production to generate your capistrano configuration.

Next we need to make some additions to our Capfile to include bundler, rails, and rbenv/rvm (if you're using them). Edit your Capfile and add these lines:


require 'capistrano/bundler'
require 'capistrano/rails'

# If you are using rbenv add these lines:
# require 'capistrano/rbenv'
# set :rbenv_type, :user # or :system, depends on your rbenv setup
# set :rbenv_ruby, '2.0.0-p451'

# If you are using rvm add these lines:
# require 'capistrano/rvm'
# set :rvm_type, :user
# set :rvm_ruby_version, '2.0.0-p451'

After we've got Capistrano installed, we can configure the config/deploy.rb to setup our general configuration for our app. Edit that file and make it like the following replacing "myapp" with the name of your application and git repository:

set :application, 'myapp'
set :repo_url, '[email protected]:excid3/myapp.git'

set :deploy_to, '/home/deploy/myapp'

set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

namespace :deploy do

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :publishing, 'deploy:restart'
  after :finishing, 'deploy:cleanup'
end

Now we need to open up our config/deploy/production.rb file to set the server IP address that we want to deploy to:

set :stage, :production

# Replace 127.0.0.1 with your server's IP address!
server '127.0.0.1', user: 'deploy', roles: %w{web app}

If you have any trouble with Capistrano or the extensions for it, check out Capistrano's Github page.

Thankfully there aren't a whole lot of things to do left!

Adding The Nginx Host

In order to get Nginx to respond with the Rails app, we need to modify it's sites-enabled.

Open up /etc/nginx/sites-enabled/default in your text editor and we will replace the file's contents with the following:

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

        server_name mydomain.com;
        passenger_enabled on;
        rails_env    production;
        root         /home/deploy/myapp/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;
        }
}

This is our Nginx configuration for a server listening on port 80. You need to change the server_name values to match the domain you want to use and in root replace "myapp" with the name of your application.

Connecting The Database

You can run cap production deploy to deploy your application.

The file config/database.yml needs to be updated for the production database server username, password, and host. You can set host to "localhost" and you will have to create a database on the server with the same name. Capistrano won't create it for you because it's something that should really only happen once. After deploying you can set create it by SSHing in and running RAILS_ENV=production bundle exec rake db:create in your app's /home/deploy/myapp/current directory (just change "myapp" to match the name of your app).

Something you should consider is only storing the database credentials on the server and having Capistrano symlink the database.yml file so that it doesn't have to be stored in git. This is especially important when you have a public git repository and don't want to publish your database credentials.

Restarting The Site

One last thing you should know is that restarting just the Rails application with Passenger is very easy. If you ssh into the server, you can run touch myapp/current/tmp/restart.txt and Passenger will restart the application for you. It monitors the file's timestamp to determine if it should restart the app. This is helpful when you want to restart the app manually without deploying it.

Conclusion

And there you have it, a very long-winded explanation of all the different things you need to do while setting up an application to be deployed. There is a lot of system administration pieces that can expand upon this, but that's for another time. Please let me know if you have any questions, comments, or suggestions!



Discussion


Gravatar
Diego Peralta on

Great tutorial!

Just one thing, the Gemfile it's wrong, it's pointing to the wrong repository of each capistrano implementation. This should work:

gem 'capistrano', '~> 3.0.0'
gem 'capistrano-bundler', '~> 1.0.0'
gem 'capistrano-rails', '~> 1.0.0'

# Add this if you're using rbenv
# gem 'capistrano-rbenv', github: "capistrano/rbenv"

# Add this if you're using rvm
# gem 'capistrano-rvm', github: "capistrano/rvm"

Cheers,
Diego

Gravatar
Chris Oliver (167,510 XP) on

Ah thanks! Fixed that up. :)


Gravatar
Eyeslandic on

Very nice tutorial, just what I needed. You should write this for digitalocean, they are offering $50 for each article now I believe.

I've always done the Postgres step a bit differently but this works too.


Gravatar
Jordan Godwin (2,680 XP) on

I keep getting error on 'rbenv:validate'? Has anyone else seen this issue or know how to resolve it?

Gravatar
Chris Oliver (167,510 XP) on

I haven't, but it seems you're not the only one https://gist.github.com/Dev...


Gravatar
David Martinez Peña on

Hi! good job.
I've followed your tutorial, I'm new in rails. This is my first app, it's working in development, and this is my first try to put in production.
Everything went ok until I have arrived to command: "cap production deploy" this returns to me an error:
cap production deploy
/home/deploy/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- capistrano/cli (LoadError)
from /home/deploy/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/bin/cap:3:in `<main>'

When following your tutorial i've used rbenv with ruby 1.9.3-p194 as in deployment-machine.
I've created database on MySQL and migrate also works.

Thanks in advance and sorry for my english.

Gravatar
Chris Oliver (167,510 XP) on

Did you make sure to include the rbenv or rvm gems for capistrano and configuration?

Gravatar
David Martinez Peña on

Hi Chris, and thank's for your quick response.
But now I'm stuck, because in development machine with simple rails s everything works great.
But if I put this folder in server and run also simple rails s my app is not showing select2 or datepickers pop-ups. Everything else is going ok.

When I solve this I'll get back and retest everything.
Thank you!.

Gravatar
Chris Oliver (167,510 XP) on

Make sure you've got those javascript files loading in the asset pipeline. Development and production can be different because of how it compiles your javascript assets.


Gravatar
Ulugbek on

Thanks for the tutorial, first of all, none of the articles at digitalocean worked for me.
I followed all the steps (using rvm for ruby installation), but when I do 'cap production deploy', I get the following error:

[email protected]:~/myapp$ cap production deploy --trace
** 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 rvm:hook (first_time)
** Execute rvm:hook
DEBUG [971a1192] Running /usr/bin/env [ -d ~/.rvm ] on 188.226.143.213
DEBUG [971a1192] Command: [ -d ~/.rvm ]
cap aborted!
deploy
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:62:in `test'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-rvm-0.1.1/lib/capistrano/tasks/rvm.rake:19:in `block (3 levels) in <top (required)="">'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/deploy/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:hook

I've been trying to fix it for a few hours now with no luck.
Any help would be appreciated,

Ulugbek

Gravatar
Chris Oliver (167,510 XP) on

Sounds like an SSH authentication problem. Take a look at the people here who also had the same problem. https://github.com/capistra...

Gravatar
Ulugbek on

Thanks, I found the problem, it was as you said in SSH authentication. I generated id_rsa.pub copy pasted content into .ssh/authorized_keys and it worked perfectly.

@eyeslandic:disqus is right, you should write this for digitalocean, would certainly help a lot of people.

Thanks again, kickass tutorial :)
Ulugbek


Gravatar
Ahmed Hashim on

Hi Chris, great tutorial! My one question is -- how can I apply this for multiple Rails apps hosted on the same Digital Ocean server?

Thanks.

Gravatar
Chris Oliver (167,510 XP) on

Pretty simple, all you need to do is to deploy multiple apps with Capistrano and setup multiple nginx server blocks. You'll be able to simply upload the new apps and everything will be already setup so long as you tell nginx to respond to those on the correct domains.

Gravatar
Ahmed Hashim on

Fantastic. You convinced me. I went with Digital Ocean and followed every step verbatim. However, when I got to the point where I had to install Passenger:

sudo apt-get install nginx-full passenger

It gave me the error: "Unable to locate package passenger"

Any help in resolving this would be appreciated.

I used RVM to install ruby.

Gravatar
Chris Oliver (167,510 XP) on

If it doesn't say it is available, make sure you ran all the commands just before it, especially: sudo apt-get update which refreshes the available packages.

Gravatar
Ahmed Hashim on

Indeed I did Chris. Especially the apt-get update command. I was quite surprised as well and was not expecting to run into this road block.

Gravatar
Chris Oliver (167,510 XP) on

Make sure you ran all the commands just before that one. It's especially important to do the sudo apt-get update after you have added the repository so that it refreshes and sees passenger as available.


Gravatar
Erik Anderson (10 XP) on

Thanks for this. I am getting an error on installing passenger, it looks like the apt source changed according to this:

http://www.modrails.com/doc...

So this:

sudo sh -c "echo 'deb https://oss-binaries.phusio... 12.04 main' >> /etc/apt/sources.list.d/passenger.list"

should be:

sudo sh -c "echo 'deb https://oss-binaries.phusio... precise main' >> /etc/apt/sources.list.d/passenger.list"

Gravatar
Chris Oliver (167,510 XP) on

Oh shoot, thanks! I missed this when I rewrote the site. Fixed now.


Gravatar
maxschulze on

I'd also add libffi-dev to the first apt-get install before compiling ruby.

Gravatar
Chris Oliver (167,510 XP) on

Not a bad idea, I'll see about adding that shortly.


Gravatar
Skimas on

Hi, amazing tutorial! Can you update it for 14.04?

Gravatar
Chris Oliver (167,510 XP) on

It is in the works! First we're waiting on the passenger package to get updated for 14.04. I'm going to try it with an older version, but we'll see.


Gravatar
Everett Carney on

I'm not sure if anyone else is getting this, but I'm running into an issue deploying my app. When I run the Capistrano deploy script it's not generating the same file structure I anticipate, here's my error:

DEBUG [e8519776] Running /usr/bin/env [ -f /home/deploy/blog/shared/config/database.yml ] on sm-beta.cloudapp.net

DEBUG [e8519776] Command: [ -f /home/deploy/blog/shared/config/database.yml ]

DEBUG [e8519776] Finished in 1.009 seconds with exit status 1 (failed).

ERROR linked file /home/deploy/blog/shared/config/database.yml does not exist on sm-beta.cloudapp.net

Looked around on Google for a bit and, supposedly, this shouldn't break my deploy which means something else is up. Any ideas where I might be able to look for other problem spots? If I ls into my blog app I only have two folders, 'releases' and 'shared'. Any thoughts/pointers are greatly appreciated!

Gravatar
Chris Oliver (167,510 XP) on

I imagine that it's trying to run migrations and the database.yml would be required for that. You can hop on to the server and create that file if you don't have it in your repo. Setup a production section with the right credentials.

Gravatar
Everett Carney on

It is trying to run migrations but that isn't the issue I'm running into. The folder structure that I would expect isn't being created.

If I do "cd blog/" then "ls" all I see are:
releases shared

There is no home/deploy/blog/current/ folder.

Gravatar
Chris Oliver (167,510 XP) on

current/ gets symlinked at a point in the deploy process that it may not have gotten done. It will operate in the releases/ folder for most of the deploy process before switching the new release over and replacing the live one. The first time you go through the process, the current/ symlink won't exist till the end.

Does that make sense?

Gravatar
Everett Carney on

Hi Chris,

Thanks for pointing that out, I got around everything by using SCP to copy the database.yml up to the server (no idea if that's normal or not but it worked).

Right now I'm getting a 403 error saying that access to .../current/public is forbidden in the nginx logs. Do you know what I might have to do to fix that? Check out the site here: railspgtest.cloudapp.net

Thanks!

Gravatar
Chris Oliver (167,510 XP) on

You may need to check and make sure the app directories are (recursively) all set to be owned by the deploy user. That's a somewhat common cause for that error.

Gravatar
Everett Carney on

I tried doing chmod -R ug+rw and it didn't seem to matter, should I try rx or is there another way I can check? Permissions look good to me: lrwxrwxrwx

Gravatar
Chris Oliver (167,510 XP) on

Permissions are probably good. You also want to check if it is owned by deploy and not root or someone else. ls -la will show you which user and group the files/folders are owned by. You can then use chown to modify that if you need to.

Gravatar
Everett Carney on

It looks like it's set up correctly, I'm still pretty green in Linux so I'm not always sure what I'm looking at. Here's the list, it seems like I own it and it has the right permissions?

drw-rw-r-- 5 deploy deploy 4096 Aug 23 21:31 emptyapp

Gravatar
Chris Oliver (167,510 XP) on

That looks correct, but you'll always want to check the sub folders too. You may also want to try changing the user to deploy in the nginx config.


Gravatar
pyasking on

hi i am newbie... help me here.. i got my app added in to github. I have digital ocean vps with ubuntu 12.04. I am deploying my app to server now.

I have done everything untill Capistrano Setup

the problem is it's confusing me mainly this line "The first step is to add Capistrano to your Gemfile". i have checked my server files using sftp client and i couldn't find it.

can you please specify the path of Gemfile please. I am almost close to deploy my app and i am stuck with this thing. It might be easy for you but i am new to rails. Please send a reply asap.

Jinu

Gravatar
Chris Oliver (167,510 XP) on

Hey Jinu, your Gemfile should be in the top folder of your Rails app. This is what defines your version of Rails and other gems that you use. You want to edit the Gemfile on your computer first (not on the server) to add Capistrano.

Gravatar
pyasking on

ok i am doing it now thanks for the quick reply

Gravatar
pyasking on

I am using rvm so i need to add this line

gem 'capistrano-rvm', github: "capistrano/rvm"

long with other three right?

Gravatar
Chris Oliver (167,510 XP) on

That's correct and you do want to do this on your local machine. Capistrano is how your local machine tells the server to deploy your code so it needs to be setup locally.

Gravatar
pyasking on

one more question chris

so we are working on local from Capistrano Setup in this tutorial right?

Gravatar
Guest on

Hi chris i got a doubt i am editing deploy.rb now. I am trying to deploy my app which is based on catarse

this is the contents of deploy.rb

# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'my_app_name'
set :repo_url, '[email protected]:me/my_repo.git'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

# Default deploy_to directory is /var/www/my_app
# set :deploy_to, '/var/www/my_app'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
# set :keep_releases, 5

namespace :deploy do

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
# execute :touch, release_path.join('tmp/restart.txt')
end
end

after :publishing, :restart

after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end

end

where i need to make edits? or do i need to replace it with your code?

please help

Jinu

Gravatar
Chris Oliver (167,510 XP) on

The simplest way is to replace it with my code and change the git repo, app name, and deploy path to match your app. After that you should be pretty much done.

Gravatar
pyasking on

hi chris in my deploy.rb file set :deploy_to, '/var/www/myapp' is default.

do i need to change it to
set :deploy_to, '/home/deploy/myapp'

Jinu


Gravatar
pyasking on

Hi Chris,

can you look in to it.

Open up /etc/nginx/sites-enabled/default in your text editor

how to do it?

Gravatar
pyasking on

when i am trying nano /etc/nginx/sites-enabled/default

a new file is opening. is that the right way?

Gravatar
Chris Oliver (167,510 XP) on

There should be an existing file there already because Nginx has a default web page it renders. You'd just be overriding it. Maybe a typo in the filename?

Nano works great. I personally use vim.


Gravatar
pyasking on

When i did cap production deploy i got following error its connecting to mydomain.com and ip address but i don't know whts happening. please someone help

cap aborted!
SocketError: getaddrinfo: Name or service not known
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `open'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `block in initialize'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/transport/session.rb:67:in `initialize'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:200:in `new'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:200:in `start'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:62:in `test'
/home/hub/.rvm/gems/ruby-2.1.0/bundler/gems/rvm-dc35ec5e7a74/lib/capistrano/tasks/rvm.rake:19:in `block (3 levels) in <top (required)="">'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:hook
(See full trace by running task with --trace)

Gravatar
Chris Oliver (167,510 XP) on

SocketError: getaddrinfo: Name or service not known means it cannot connect to the IP address / domain that you put in. Make sure you don't have any typos and that you specified your domain correctly.

Gravatar
pyasking on

cap production deploy
DEBUG [76ec8393] Running /usr/bin/env [ -d ~/.rvm ] on ownmanager.co
DEBUG [76ec8393] Command: [ -d ~/.rvm ]
DEBUG [2cb0418b] Running /usr/bin/env [ -d ~/.rvm ] on 162.243.44.48
DEBUG [2cb0418b] Command: [ -d ~/.rvm ]
cap aborted!
SocketError: getaddrinfo: Name or service not known

hi this is waht happening then followed by the above error. these two are my domain name and ip

Gravatar
Chris Oliver (167,510 XP) on

Hmm. I guess next steps is to verify you can ssh in by doing ssh [email protected] with the password you set earlier.

Gravatar
pyasking on

hi i can verify and i am in [email protected]

Gravatar
Chris Oliver (167,510 XP) on

The other possibility then is your git connection isn't working properly. When you deploy, your server pulls down from git, so maybe it isn't able to connect to your git repo, but I don't think your deploy has gotten that far. I'm not quite sure. Keep double checking your configs and maybe you'll spot the error.

Gravatar
pyasking on

i am pasting my production.rb here can you check it

# Simple Role Syntax
# ==================
# Supports bulk-adding hosts to roles, the primary
# server in each group is considered to be the first
# unless any hosts have the primary property set.
# Don't declare `role :all`, it's a meta role
role :app, %w{[email protected]}
role :web, %w{[email protected]}
role :db, %w{[email protected]}

# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server
# definition into the server list. The second argument
# something that quacks like a hash can be used to set
# extended properties on the server.

set :stage, :production

server '162.243.44.48', user: 'deploy', roles: %w{web app}

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/ne...
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options

Gravatar
Chris Oliver (167,510 XP) on

I believe your roles there at the top might be causing the problem. You don't want those to include the "[email protected]" in them because it gets added automatically. Comment out those lines because the server line you have later takes care of that.

Gravatar
pyasking on

i did taht,

now i am getting this

cap production deploy
DEBUG [4e69742b] Running /usr/bin/env [ -d ~/.rvm ] on 162.243.44.48
DEBUG [4e69742b] Command: [ -d ~/.rvm ]
cap aborted!
Net::SSH::AuthenticationFailed: deploy

/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/connection_pool.rb:25:in `create_or_reuse_connection'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:173:in `ssh'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:126:in `block in _execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:62:in `test'
/home/hub/.rvm/gems/ruby-2.1.0/bundler/gems/rvm-dc35ec5e7a74/lib/capistrano/tasks/rvm.rake:19:in `block (3 levels) in <top (required)="">'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => rvm:hook
(See full trace by running task with --trace)

Gravatar
Chris Oliver (167,510 XP) on

That's good. Did you run the ssh-copy-id command? If so, when you ssh in it should not ask you for a password. If it does, that might be the missing piece because it isn't generally good to use passwords for ssh.


Gravatar
pyasking on

hi,

my app using rvm 2.1.1 do i need to use the same in server

Gravatar
Chris Oliver (167,510 XP) on

It's best to use the same setup on the server if you can. Definitely make sure you're using the same version of Ruby to be on the safe side otherwise bugs can come up. I would upgrade to 2.1.2 because 2.1.1 had compile bugs with readline on Ubuntu.

Gravatar
pyasking on

hi chris i have done cap production deploy.. the files are in server. thanks to your guidence. now how to setup the databse connection. when i did cap production deploy my database.yml file didn't uploaded in to server. i have put it in the server using sftp now. After deploying, i tried RAILS_ENV=production bundle exec rake db:create it's showing and error "couldn't locate Gemfile". what's wrong here?

Gravatar
Chris Oliver (167,510 XP) on

Great! :) Are you in the app's current directory?

Gravatar
pyasking on

i got two directories in my server /home/deploy/myapp/shared and
/home/deploy/myapp/released no
/home/deploy/myapp/current

Gravatar
Chris Oliver (167,510 XP) on

Ah okay, so either cd into one of the releases folders (capistrano may have removed failed deploys so there may not be any) and run the rake db:create or open up the mysql command line and create the database manually instead.

Gravatar
pyasking on

ok chris, in my local development i have created a develpemnt database user and pass.. in production do i need to use the same values.

after creating do i need to run rake db:migrate and rake db:seed ?

Gravatar
Chris Oliver (167,510 XP) on

Correct, you'll want to do both of those after creating.

You can deploy as many times as you need safely. It will keep copies in the releases folder. When it is successful, it will symlink it to the current folder that we just talked about.

Gravatar
pyasking on

thanks for the help

Gravatar
Chris Oliver (167,510 XP) on

No problem!

Gravatar
pyasking on

chris a new error while deploying Bundler::GemNotFound: Could not find minitest-4.7.5.gem for installation

Gravatar
Chris Oliver (167,510 XP) on

Minitest is used for development so you should not see this in production. Are you sure you used RAILS_ENV=production everywhere?

Gravatar
pyasking on

hi chris,

i tried cap production deploy again.. most of the file transfer was success and finally i got an error. can check it?
cap aborted
SSHKit::Command::Failed: bundle stdout: Nothing written
bundle stderr: Nothing written
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `call'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `call'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:205:in `process'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/net-ssh-2.7.0/lib/net/ssh/connection/session.rb:169:in `loop'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/hub/.rvm/gems/ruby-2.1.0/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:30:in `block (5 levels) in <top (required)="">'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:89:in `with'
/home/hub/.rvm/gems/ruby-2.1.0/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:22:in `block (4 levels) in <top (required)="">'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'
/home/hub/.rvm/gems/ruby-2.1.0/gems/capistrano-bundler-1.1.2/lib/capistrano/tasks/bundler.cap:21:in `block (3 levels) in <top (required)="">'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/home/hub/.rvm/gems/ruby-2.1.0/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: #<sshkit::command::failed: bundle="" stdout:="" nothing="" written="" bundle="" stderr:="" nothing="" written="">

Gravatar
Chris Oliver (167,510 XP) on

Haven't seen that before. Does this help? http://stackoverflow.com/qu...

Gravatar
pyasking on

I am using catarse as i told you. my default deploy.rb saying the # Default deploy_to directory is /var/www/my_app but i set it to home/deploy/my_app based on your guide will it make a difference

Gravatar
Chris Oliver (167,510 XP) on

That will work just fine.

Gravatar
pyasking on

ok

Gravatar
pyasking on

one more thing i hve tried cap production deploy once.. can i do it again.. will it update the server files.


Gravatar
pyasking on

hi chris
are you here?
i got a doubt


Gravatar
pyasking on

when i am deploying my app, the deploy path should be new or an already created app? which means when i push my contents. it will got to /home/deploy/myapp

i am just deploying my respo to /home/deploy/myapp (where my app is a fresh directory).

do i need to create scratch rails app before deploying?

then deploy my app in to the scratch rails app?


Gravatar
pyasking on

i have deployed my app to digital ocean. i got current directory. but when i visit current folder and try RAILS_ENV=production bundle exec rake db:create it's saying to bundle install first.

when i am trying to bundle install in current it'd saying install git. i couldn't install git in current right/?

so whats wrong here?


Gravatar
pyasking on

hi chris i done deploy successfully using your guide. the only problem is i am still gettng nginx page on my ip.


Gravatar
pyasking on

i tried touch myapp/current/tmp/restart.txt and it didn't started my app. the ip still showing nginx welcome. wht i did worng here?

Gravatar
Chris Oliver (167,510 XP) on

You'll need to make sure you delete the default server block for Nginx, add your Rails one, and then run "sudo service nginx restart" to load all those new configs.

Gravatar
pyasking on

that helped

Gravatar
pyasking on

my app in online now. but the registration is not working.. if i make achange in shared folder in my app directory will it update to current? i don't want to do deploy again.. so iwan to edit files using ftp and try to make changes in current. is that possible?

Gravatar
Chris Oliver (167,510 XP) on

It's best to make the changes, commit them, and deploy again. Now that you have everything working, the site will just seamlessly update when you deploy.

If you just want to tweak one of the config files in shared that isn't part of the Rails app (like database.yml) you can edit this file manually and them touch tmp/restart.txt


Gravatar
Guest on

hi chris,

i got an error when i am doing seed after deploy... can you tell me whats worng

[schema_associations] Authorization.belongs_to :oauth_provider, :class_name=>"OauthProvider", :foreign_key=>"oauth_provider_id", :inverse_of=>:authorizations
[schema_associations] Authorization.belongs_to :user, :class_name=>"User", :foreign_key=>"user_id", :inverse_of=>:authorizations
Rendered custom/devise/mailer/confirmation_instructions.en.html.slim within layouts/email (30.6ms)
rake aborted!
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/http/url.rb:59:in `build_host_url'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/http/url.rb:40:in `url_for'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:670:in `url_for'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:401:in `url_for'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:234:in `call'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:178:in `call'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:274:in `block (2 levels) in define_url_helper'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/routes_proxy.rb:31:in `user_confirmation_url'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/routes_proxy.rb:34:in `method_missing'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/lib/devise/controllers/url_helpers.rb:50:in `confirmation_url'
/home/deploy/silcom/releases/20140530151732/app/views/custom/devise/mailer/confirmation_instructions.en.html.slim:7:in `_app_views_custom_devise_mailer_confirmation_instructions_en_html_slim__458522283_113549150'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/template.rb:143:in `block in render'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:161:in `instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/template.rb:141:in `render'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `block in instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/template_renderer.rb:47:in `render_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/template_renderer.rb:17:in `render'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/renderer.rb:42:in `render_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/action_view/renderer/renderer.rb:23:in `render'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/rendering.rb:127:in `_render_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/rendering.rb:120:in `render_to_body'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/rendering.rb:97:in `render'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:755:in `block in collect_responses'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:769:in `each'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:769:in `each_template'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:751:in `collect_responses'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:691:in `mail'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/lib/devise/mailers/helpers.rb:16:in `devise_mail'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/app/mailers/devise/mailer.rb:6:in `confirmation_instructions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/base.rb:189:in `process_action'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in `_run__527241932__process_action__callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/callbacks.rb:17:in `process_action'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/base.rb:136:in `process'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionpack-4.0.2/lib/abstract_controller/rendering.rb:44:in `process'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:503:in `process'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:497:in `initialize'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:480:in `new'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:480:in `method_missing'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/lib/devise/models/authenticatable.rb:175:in `send_devise_notification'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/devise-3.1.2/lib/devise/models/confirmable.rb:158:in `send_on_create_confirmation_instructions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:386:in `_run__437918340__create__callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in `create_record'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/timestamp.rb:57:in `create_record'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:477:in `create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:413:in `_run__437918340__save__callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `block in save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `block in save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block (2 levels) in around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:150:in `block in run_actions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:170:in `catch_exceptions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:148:in `run_actions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:133:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:212:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block (2 levels) in perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `catch'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block in perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:186:in `within_transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:62:in `perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block in around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:530:in `block in transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:529:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:501:in `around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/protected_attributes-1.0.5/lib/active_record/mass_assignment_security/validations.rb:17:in `create!'
/home/deploy/silcom/releases/20140530151732/db/seeds.rb:135:in `<top (required)="">'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:540:in `load_seed'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:154:in `load_seed'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)="">'
Tasks: TOP => db:seed
(See full trace by running task with --trace)

Gravatar
Chris Oliver (167,510 XP) on

Well it says: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

So you need to set that in your different environment.rb files. Probably forgot to add that in your production.rb

Gravatar
pyasking on

sorry, i really didn't understand it. can you help me with this i have followed your guide to deploy.. how the code looks like... where i need to add it?

Gravatar
Chris Oliver (167,510 XP) on

You can add config.action_mailer.default_url_options = { host: 'yourdomain.com' } to your config/production.rb file. Just change "yourdomain.com" to the domain or IP address you are using.

Gravatar
pyasking on

i have added in to production.rb. deployed again and tried rakedb:migrate and seed... while doing seed i got the following error.. what is it?

rake aborted!
435 4.7.8 Error: authentication failed:
/home/deploy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:456:in `block in deliver_mail'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `block in instrument'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in `instrument'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/actionmailer-4.0.2/lib/action_mailer/base.rb:454:in `deliver_mail'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/devise-3.1.2/lib/devise/models/authenticatable.rb:175:in `send_devise_notification'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/devise-3.1.2/lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/devise-3.1.2/lib/devise/models/confirmable.rb:158:in `send_on_create_confirmation_instructions'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:386:in `_run__729100180__create__callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in `create_record'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/timestamp.rb:57:in `create_record'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:477:in `create_or_update'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:413:in `_run__729100180__save__callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `create_or_update'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in `save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in `save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `block in save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `block in save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block (2 levels) in around_save'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:150:in `block in run_actions'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:170:in `catch_exceptions'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:148:in `run_actions'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:133:in `run_callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:212:in `run_callbacks'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block (2 levels) in perform'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `catch'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block in perform'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:186:in `within_transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:62:in `perform'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block in around_save'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:530:in `block in transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:529:in `transaction'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:501:in `around_save'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `save!'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/protected_attributes-1.0.5/lib/active_record/mass_assignment_security/validations.rb:17:in `create!'
/home/deploy/silcom/releases/20140530151732/db/seeds.rb:135:in `<top (required)="">'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:540:in `load_seed'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:154:in `load_seed'
/home/deploy/.rvm/gems/ruby-2.1.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)="">'
/home/deploy/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/home/deploy/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)


Gravatar
Guest on

hi i got one more error. while seeding, can you tell my i am seeing this... do i need to start redis-server in production server too?

2014-05-30T18:17:32Z 20938 TID-14fa9g INFO: Sidekiq client with redis options {}
rake aborted!
Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:278:in `rescue in establish_connection'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:273:in `establish_connection'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:69:in `connect'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:292:in `ensure_connected'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:179:in `block in process'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:258:in `logging'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:178:in `process'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:149:in `call_pipelined'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:121:in `block in call_pipeline'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:245:in `with_reconnect'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis/client.rb:119:in `call_pipeline'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis.rb:2093:in `block in multi'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis.rb:36:in `block in synchronize'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis.rb:36:in `synchronize'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/redis-3.0.6/lib/redis.rb:2085:in `multi'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:159:in `block in raw_push'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/connection_pool-1.2.0/lib/connection_pool.rb:55:in `with'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq.rb:67:in `redis'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:150:in `raw_push'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:50:in `push'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:98:in `push'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/worker.rb:83:in `client_push'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/sidekiq-2.17.0/lib/sidekiq/worker.rb:40:in `perform_async'
/home/deploy/silcom/releases/20140530162625/app/observers/user_observer.rb:10:in `after_create'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/rails-observers-0.1.2/lib/rails/observers/active_model/observing.rb:352:in `update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/rails-observers-0.1.2/lib/rails/observers/activerecord/observer.rb:118:in `block (2 levels) in define_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:454:in `_run__319964337__create__callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:306:in `create_record'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/timestamp.rb:57:in `create_record'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:477:in `create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `block in create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:413:in `_run__319964337__save__callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/callbacks.rb:302:in `create_or_update'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/persistence.rb:128:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/validations.rb:57:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/dirty.rb:41:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `block in save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:326:in `block in with_transaction_returning_status'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:200:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:323:in `with_transaction_returning_status'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:275:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `block in save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block (2 levels) in around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:150:in `block in run_actions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:170:in `catch_exceptions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:148:in `run_actions'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:133:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:212:in `run_callbacks'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block (2 levels) in perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `catch'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:63:in `block in perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:186:in `within_transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/transition_collection.rb:62:in `perform'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:502:in `block in around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:530:in `block in transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `block in transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:210:in `within_new_transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:202:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/transactions.rb:209:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:529:in `transaction'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:501:in `around_save'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/state_machine-1.2.0/lib/state_machine/integrations/active_record.rb:487:in `save!'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/protected_attributes-1.0.5/lib/active_record/mass_assignment_security/validations.rb:17:in `create!'
/home/deploy/silcom/releases/20140530162625/db/seeds.rb:135:in `<top (required)="">'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/railties-4.0.2/lib/rails/engine.rb:540:in `load_seed'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/tasks/database_tasks.rb:154:in `load_seed'
/home/deploy/silcom/shared/bundle/ruby/2.1.0/gems/activerecord-4.0.2/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)="">'
Tasks: TOP => db:seed
(See full trace by running task with --trace)

Gravatar
Chris Oliver (167,510 XP) on

Yeah you'll need to run redis-server in production if you use sidekiq.

Gravatar
pyasking on

hi chris,

i am having another issue hope you can help me i am using mandrill for user confirmation mails...it's sending confirmation mails to users but when user clicks on confirm my email link.. the is not redirection to my site. when i check the url i found that. http://domain/password/edit?reset_password_token=secrettoken.... it should be http://domain.com/password/.......

how to solve it. can you give me a tip

Gravatar
Chris Oliver (167,510 XP) on

Should be as simple as adding in the ".com" to the host thing in your production.rb that you added earlier I believe.


Gravatar
Nick on

Thanks Chris - your tutorial is simply awesome. It's the clearest I could find.

I have an issue though. I followed the tutorial and the deployment was successful. Yet I can't see the app. I can see the Nginx start page at the IP of my droplet (http://5.101.99.81/) but I can't see the app. Locally I see it at localhost:3000/todos but nothing of that sort can be seen at the DO instance. The only place I deviated from your tutorial was at the /etc/nginx/sites-enabled/default.Instead of using server_name mydomain.com; I used the IP address: server_name 5.101.99.81; as I haven't registered the domain yet. Do you think that this is the cause? If not - what else could be wrong?

Gravatar
Chris Oliver (167,510 XP) on

That would be a problem with your nginx config. The IP address doesn't matter, it's okay to serve up on that instead of a domain. You may have changed the config and not restarted nginx or you did and it was invalid and nginx didn't actually load it. Double check that and the /var/log/nginx/error.log file to see if you have anything wrong there.

Gravatar
Nick on

Thanks, Chris! I found the problems - there are two things that I had to tweak in the recipe that you provide. First was finding the proper passenger_ruby path and the second was related to the permissions of the parent directories. I described these in greater detail here: http://feraldeveloper.blogs...

Gravatar
Chris Oliver (167,510 XP) on

Great post Nick. That will be useful for anyone running into trouble with rvm. I'll be sure to point people that direction if they have issues. :)


Gravatar
Matt Gardner on

Thank you for the great tutorial. I feel a lot more comfortable with Capistrano.

I'm struggling somewhat with Passenger:

"Ruby (Rack) application could not be started"

It cites a problem with the Gemfile ("There was an error in your Gemfile, and Bundler cannot continue. (Bundler::GemfileError)")

And in the Backtrace, it points to an old version of Ruby I had installed on there:
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/bundler-1.1.5/lib/bundler/dsl.rb12in `evaluate'

Any idea how to get Passenger to stop using REE? I have a feeling it's simply an old version of Bundler that is struggling with my more current Gemfile.

Gravatar
Chris Oliver (167,510 XP) on

Make sure your passenger_ruby line in nginx.conf points to the right location. I think if that fails, it probably falls back to whatever is in your PATH which could be an older version like REE.

Gravatar
Guest on

Thank you, Chris - I'm using Apache for this deployment. The config file for the Passenger module in Apache does point to an older version of Ruby, not the one I installed via RVM. I think if I can point Passenger to the correct Ruby and Ruby gems, I'll have better luck. @disqus_tyxDkqZxms:disqus's post I think alludes to the problem.

Gravatar
Matt Gardner on

Thank you, Chris - I'm using Apache for this deployment. The conf file for the Passenger module in Apache does point to an older version of Ruby, not the one I installed via RVM. I think if I can point Passenger to the correct Ruby and Ruby gems, I'll have better luck. @disqus_tyxDkqZxms:disqus 's post I think alludes to the problem. (http://feraldeveloper.blogs...

Gravatar
Chris Oliver (167,510 XP) on

Are you using rbenv, rvm, or something else? That'll help determine what you need and then your ruby version just kind of replaces part of a config line for that.

Gravatar
Matt Gardner on

I was using RVM, which I installed to my user path, but the Apache error log was giving me permission errors when I pointed the configs to Ruby and the Passenger gem. This was essentially the error: http://stackoverflow.com/qu.... But, linux wasn't happy with the solution (using chcon on the passenger path). I thought maybe this had to do with the server configuration (it's not my server), so I decided to try a different approach, which is to try rbenv and install to a public directory rather than my home directory.

Gravatar
Matt Gardner on

Hi Chris,

I'm using rvm for this. Good news, however: I successfully deployed! I think some of the locations of ruby, rvm, and passenger aren't correct, but I have a working website.

New issue:

I can't "cap production deploy" anymore. It fails with this:

INFO[ec083304] Running /usr/bin/env git remote update on livingwage-staging.mit.edu

DEBUG[ec083304] Command: cd /var/www/vhosts/livingwage.mit.edu/repo && /usr/bin/env git remote update

DEBUG[ec083304] error: cannot open FETCH_HEAD: Permission denied

DEBUG[ec083304]

cap aborted!

SSHKit::Runner::ExecuteError: Exception while executing on host livingwage-staging.mit.edu: git exit status: 1

Full log: http://pastebin.com/ziK22BGX

I feel I've scoured the internet for a solution, but I can't find anything for this particular issue. Could you point me in a possible direction for research? Once I can get this fixed, I will be done.

Thank you so much!

Gravatar
Chris Oliver (167,510 XP) on

Sounds like it's having trouble reading from your Git repo. I'd guess none of that has changed, but you might want to double check it. You can also do the ssh forward agent option if you want to use your local ssh keys to check out the repo in case that is causing the problem. Other than something related to that, I don't know what's wrong.

Gravatar
Matt Gardner on

It was a permissions issue. Everything was set to nogroup somehow.


Login or create an account to join the conversation.