Ask A Question

Notifications

You’re not receiving notifications from this thread.

Deploy Rails

Artem Kiryanov asked in Servers

Hi . Can you help me ? When i start : cap deploy production, i have errors:

  1. rake stdout: Nothing written
  2. rake stderr: syck has been removed, psych is used instead

How can i resolve them?

Reply

Can you paste the full logs? For #2, you are probably using something that uses an old YAML parser. Maybe need to update gems or something for it to get fixed.

Reply

My Gemfile:

group :production do
  gem 'pg'
   gem 'capistrano', '~> 3.3.0'
   gem 'capistrano-bundler', '~> 1.1.2'
   gem 'capistrano-rails', '~> 1.1'
   gem 'capistrano-rvm'
   gem 'sshkit'
end
My Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails'


  require 'capistrano/rvm'
  set :rvm_type, :user
  set :rvm_ruby_version, '2.1.3-p242'


# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }

My config/deploy.rb

set :default_env, {
 :PATH => '/home/deploy/.rvm/gems/ruby-2.1.3-p242/bin:/home/deploy/.rvm/gems/ruby-2.1.3-p242@global/bin:/home/deploy/.rvm/rubies/ruby-2.1.3-p242/bin:/home/deploy/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games'
} 
set :application, 'lifeblog'
set :repo_url, 'git@github.com:hacker342/lifeblog.git'
  set :deploy_to, '/home/deploy/lifeblog'
 set :linked_files, %w{config/database.yml}
 set :linked_dirs, %w{bin 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
      # Your restart mechanism here, for example:
       execute :touch, release_path.join('tmp/restart.txt')
    end
  end

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

end

My config/deploy/production.rb

role :app, %w{deploy@104.236.45.52}
role :web, %w{deploy@104.236.45.52}
role :db,  %w{deploy@104.236.45.52}


# Extended Server Syntax
# ======================
# This can be used to drop a more detailed server definition into the
# server list. The second argument is a, or duck-types, Hash and is
# used to set extended properties on the server.

set :stage, :production

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

I fixed my 1 and 2 problem, but, when i put cap production deploy, i have error:

(Backtrace restricted to imported tasks)
cap aborted!
Don't know how to build task 'deploy:setup'
Reply

Okey, i fixed this problem, but i have new error:

The deploy has failed with an error: Exception while executing on host 104.236.45.52: rake exit status: 1
rake stdout: Nothing written
rake stderr: syck has been removed, psych is used instead
PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "104.236.45.52" and accepting
    TCP/IP connections on port 5432?
Reply

That last bit is basically just saying that it can't find a running Postgres server on that IP address. Make sure it's running on your server and that you've got the right IP. If you are running Postgres on the same server as Rails, you can use 127.0.0.1 instead of the server's IP address so it can just connect locally.

Reply

Okey , Thank you! I fixed that lost error, i reinstall capistrano and droplet, but when i cap production deploy, i have error:

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 104.236.45.52: bundle exit status: 16
bundle stdout: Nothing written
bundle stderr: Nothing written
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `call'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:551:in `do_request'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:561:in `channel_request'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:269:in `wait'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:170:in `block (3 levels) in _execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:221:in `preprocess'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `block in loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:169:in `loop'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:172:in `block (2 levels) in _execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:186:in `with_ssh'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:131:in `block in _execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `tap'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:128:in `_execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/home/rails/.rvm/gems/ruby-2.1.3/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:35:in `block (5 levels) in '
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:85:in `with'
/home/rails/.rvm/gems/ruby-2.1.3/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:26:in `block (4 levels) in '
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/abstract.rb:77:in `within'
/home/rails/.rvm/gems/ruby-2.1.3/gems/capistrano-bundler-1.1.3/lib/capistrano/tasks/bundler.cap:25:in `block (3 levels) in '
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:54:in `run'
/home/rails/.rvm/gems/ruby-2.1.3/gems/sshkit-1.5.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
SSHKit::Command::Failed: bundle exit status: 16
bundle stdout: Nothing written
bundle stderr: Nothing written
Reply

Okey. I fixed this problem. How can i fixed ?
First ! Open ssh server and put command: which ruby and copy this.

  1. Open rails_app on my local machine and open deploy.rb , and paste line from terminal
set :default_env, {
    :PATH => '/home/deployer/.rvm/gems/ruby-2.0.0-p353/bin:/home/deployer/.rvm/gems/ruby-2.0.0-p353@global/bin:/home/deployer/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/deployer/.rvm/bin'
}

And git add and commit , then cap production deploy

Reply

Good find! I've had to do that a couple times before but I can't remember the exact situation that required setting the env. This is good to note and hopefully helpful for other people running into similar problems.

Reply

Okey, Chris! But, I can't fix this problem. When i open my site, i see 403 error . Why?
My nginx.log

2014/12/02 02:18:30 [error] 6712#0: *24 directory index of "/home/deploy/lifeblog/current/public/" is forbidden, client: 66.249.69.153, server: www.artkiryanov.ru, request: "GET / HTTP/1.1", host: "artkiryanov.ru"
2014/12/02 02:50:39 [error] 6712#0: *25 directory index of "/home/deploy/lifeblog/current/public/" is forbidden, client: 93.125.59.125, server: www.artkiryanov.ru, request: "GET / HTTP/1.1", host: "artkiryanov.ru"

And My /etc/nginx/sites-enabled/default

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

        server_name www.artkiryanov.ru  artkiryanov.ru
        passenger_enabled on;
        rails_env production;
        root /home/deploy/lifeblog/current/public;


        # Make site accessible from http://localhost
#       error_page 500 502 503 504 /50x.html;
#       location = /50x.html {
#               root html;
#       }
}

How can I solve the problem ?

Reply

Chris! I fixed my problem! How?

First! Open /etc/nginx/sites-enabled/default and comment location directory
It is my settings

server {
        listen 80;
        server_name www.artkiryanov.ru artkiryanov.ru
        rails_env production;
        passenger_use_global_queue on;
        root /home/deploy/lifeblog/current/public;
        passenger_enabled on;

#       # Make site accessible from http://localhost
#       error_page 500 502 503 504 /50x.html;
#       location = / {
#           passenger_enabled on;
#
#       }
}

And Restart nginx! Nice! Work!

Reply
Join the discussion
Create an account Log in

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

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

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