I'm trying to deploy my rails app called Blog to my website through Capistrano. I have created a Rails App in cPanel at /rails_app/Blog/ and have deleted the skeleton code that was generated.
When i type this command in the terminal
cap deploy:setup
I get this error message
USER#USER-PC ~/documents/Aptana Studio 3 Workspace/Blog
$ cap deploy:setup
* executing `deploy:setup'
* executing "sudo -p 'sudo password: ' mkdir -p /rails_app/Blog/ /rails_app/Bl
og/releases /rails_app/Blog/shared /rails_app/Blog/shared/system /rails_app/Blog
/shared/log /rails_app/Blog/shared/pids"
servers: ["mydomain.co.nz"]
connection failed for: mydomain.co.nz (Errno::ETIMEDOUT: A connection attempt fail
ed because the connected party did not properly respond after a period of time,
or established connection failed because connected host has failed to respond. -
connect(2))
Here is my deploy.rb file config settings
set :application, "mydomain.co.nz"
set :repository, "set your repository location here"
set :scm, :subversion
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
# These are not not part of the defaults
set :port, 12002
set :deploy_to, "/rails_app/Blog/"
#
role :web, application # Your HTTP server, Apache/etc
role :app, application # This may be the same as your `Web` server
role :db, application, :primary => true # This is where Rails migrations will run
role :db, application
try this, this is example of deploy.rb file that work for me
require "bundler/capistrano"
set :application, "testcapistrano"
set :rvm_ruby_string, "ruby-1.9.3-p194#testcapistrano"
require "rvm/capistrano"
set :rvm_type, :user
set :rvm_install_ruby, :install
set :repository, "xyz"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "testcapistrano.dipak.cs" # Your HTTP server, Apache/etc
role :app, "testcapistrano.dipak.cs" # This may be the same as your `Web` server
role :db, "testcapistrano.dipak.cs", :primary => true # This is where Rails migrations will run
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/dipak/capistron/"
set :deploy_via, :remote_cache
set :user, "your username"
set :password, "password"
set :use_sudo, false
set :keep_releases, 5
before 'deploy:setup', 'rvm:install_ruby'
# tasks
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
end
Related
This is my first time to deploy a rails app in DigitalOcean, but I'm having a problem in deploying the application. When I tried to run the cap production deploy or bundle exec cap deploy:setup I got an error of :
/usr/local/rvm/gems/ruby-2.2.0/gems/capistrano-bundler-1.1.4/lib/capistrano/tasks/bundler.cap:1:in `<top (required)>': undefined method `namespace' for main:Object (NoMethodError)
this is my deploy.rb
set :application, "myapp.com"
set :repository, "git#heroku.com:myapp.git"
set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :user, 'user'
set :use_sudo, false
set :deploy_to, "/home/user/video-benta"
set :deploy_via, :remote_cache
role :web, "myapp.com" # Your HTTP server, Apache/etc
role :app, "myapp.com" # This may be the same as your `Web` server
role :db, "myapp", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
namespace :deploy do
task :bundle_gems do
run "cd #{deploy_to}/current && bundle install vendor/gems"
end
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
Capfile ( Update )
load 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
require 'capistrano/bundler'
require 'capistrano/rails'
# If you are using rvm add these lines:
require 'capistrano/rvm'
set :rvm_type, :user
set :rvm_ruby_version, '2.2.0p0'
You are trying to use different Capistrano extensions incompatible with your Capistrano version. Your Capistrano version is 2.x (detected by format of your Capfile), but capistrano/bundler for example is a extension for Capistrano 3.x.
Just use Capistrano 3 (if possible) and compatible extensions.
i wonder why my cap deployment fails.
I am using capistrano.
Here's my deploy.rb:
set :application, "gppb"
set :repository, "git#github.com:AppSource/gppb.git"
set :scm, :git
set :user, "gppb.com"
set :deploy_to, "/home/gppb.com/apps/#{application}"
set :use_sudo, false
set :keep_releases, 5
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "test.gppb.appsource.biz" # Your HTTP server, Apache/etc
role :app, "test.gppb.appsource.biz" # This may be the same as your `Web` server
role :db, "test.gppb.appsource.biz", :primary => true # This is where Rails migrations will run
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
And here is the error:
To see the full image click here-> http://d.pr/i/wnIb
Looks like you should set your :user to "gppbv2". That's the parameter for the remote user on the server. Also, Unix usernames can't have periods in them.
Am following a nice tutorial here and it's really helped wrap my head around some things. Rails apache and rvm all work nicely together. I'm almost finished but am getting stuck on the final part.
Basically I have the deploy file similar to what he has but cant seem to debug what he's looking for.The deploy.rb file looks like this:
#RVM Bootstrap
$:.unshift(File.expand_path('./lib',ENV['rvm_path']))
require 'rvm/capistrano'
set :rvm_ruby_string, '1.9.2-p318'
#bundler bootstrap
require 'bundler/capistrano'
#main details
set :application , "test"
role :web, "test"
role :app, "test"
role :db, "test", :primary => true
#server Details
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/test/"
set :deploy_via, :remote_cache
set :user, "passenger"
set :use_sudo, false
# repo details
set :scm, :git
set :scm_username, "passenger"
set :repository, "git#gitserver:test.git"
set :branch, "master"
set :git_enable_submodules, 1
# tasks
namespace :deploy do
task :start, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
task :stop, :roles => :app do
# Do nothing.
end
desc "Restart Application"
task :restart, :roles => :app do
run "touch #{current_path}/tmp/restart.txt"
end
end
When I attempt to deploy the application with capistrano with cap deploy:setup
I get the following error:
* executing `deploy:setup'
* executing "mkdir -p /var/www/test/ /var/www/test/releases /var/www/test/shared /var/www/test/shared/system /var/www/test/shared/log /var/www/test/shared/pids"
servers: ["test"]
connection failed for: test (SocketError: getaddrinfo: Name or service not known)
I've tinkered with it a bit. Rails webrick has no problems starting the rails application so it must be something to do with me deploying to apache. One thing to note is that the application name "app" (because test is reserved in rails) and the domain name is "test".
This mismatch could be causing problems but I have little to no experience so I'm not sure.
Can anyone point me where to debug or what it might be?
Role web, app and db need to be the URL or IP of the server that you're deploying to. Something like this:
task :staging do
set :rails_env, 'staging'
role :app, "example.com"
role :web, "example.com"
role :db, "example.com", :primary => true
end
When I deploy with capistrano I get an error (and rollback) when capistrano attempts to run assets:precompile.
I'm using rails 3.2.1, bundler 1.0.22, capistrano 2.11.2
If I run rake assets:precompile from /webapps/myapp/current it runs successfully.
error:
failed: "sh -c 'cd /webapps/myapp/releases/20120304160347 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'"
deploy.rb
require "bundler/capistrano"
load 'deploy/assets'
set :application, "myapp"
set :domain, '24.17.71.95'
set :repository, "."
set :deploy_via, :copy
set :local_repository, '/home/me/myapp/.git'
set :deploy_to, '/webapps/myapp/'
set :scm, :none #:git
set :user, 'me'
set :password, 'me$pw'
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
default_run_options[:pty] = true
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Rails migrations will run
set :branch, 'master'
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
before "deploy:assets:precompile", "bundle:install"
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
As far as I know, the asset precompiling task should be one of the last (or even the last one) tasks that are beeing executed.
So please try to move
load 'deploy/assets'
out of deploy.rb into Capfile (root folder of your Rails app) and paste it as the last line of the file.
See my answer to this Stackoverflow question.
If that fails, try the advice in http://www.simonecarletti.com/blog/2012/02/heroku-and-rails-3-2-assetprecompile-error/
When trying to deploy with Capistrano I am getting a ton of these errors:
[err :: localhost] tar: 20120220182722/app/assets/images/assets/Thumbs.db: Cannot open: No such file or directory
Every asset I have can't be found and capistrano errors out (doing a deploy:cold)
I've uncommented this line in the capfile:
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
but it still says the same thing.
The above line is actually in my Capfile here is the rest of my deploy.rb (note that I am using vagrant and trying to deploy to a VM created with vagrant)
require 'bundler/capistrano'
set :application, "testdeploy"
set :scm, :git
set :repository, "."
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
server "localhost", :app, :db, :primary => true
ssh_options[:port] = 2222
ssh_options[:keys] = "~/.rvm/gems/ruby-1.9.3-p125#testdeploy/gems/vagrant-0.9.4/keys/vagrant"
set :user, "vagrant"
set :group, "vagrant"
set :deploy_to, "/var/testdeploy"
set :use_sudo, true
set :deploy_via, :copy
set :copy_strategy, :export
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end