Here is the output of executing of deploy.rb with cap deploy, on ubuntu & rvm:
when executing .../bin/bundle install vendor/gem, the error comes:
* executing "cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
servers: ["12.34.56.78"]
[12.34.56.78] executing command
*** [err :: 12.34.56.78] /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8] (Gem::LoadError)
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
*** [err :: 12.34.56.78] from /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle:18:in `<main>'
command finished in 624ms
failed: "sh -c 'cd /vol/www/emclab/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems'" on 12.34.56.78
Here is the output of cap invoke COMMAND='which bundle':
** [out :: 12.34.56.78] /usr/local/bin/bundle
Here is the deploy.rb:
set :application, "myapp"
set :repository, "git://github.com/myapp/myapp.git"
set :scm, :git
set :user, "dtt"
set :use_sudo, true
set :scm_passphrase, "phrase"
set :branch, "master"
set :deploy_to, "/vol/www/#{application}"
#set :deploy_via, :remote_cache
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
server "12.34.56.78", :web, :app, :db, :primary => true
#role :web, "your web-server here" # Your HTTP server, Apache/etc
#role :app, "your app-server here" # This may be the same as your `Web` server
#role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
after "deploy", "deploy:bundle_gems"
after "deploy:bundle_gems", "deploy:restart"
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :bundle_gems do
run "cd #{deploy_to}/current && /home/dtt/.rvm/gems/ruby-1.9.2-p290/bin/bundle install vendor/gems"
end
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
Any suggestions about the error? Thanks.
Get cap to connect and tell you where bundle is installed
cap invoke COMMAND='which bundle'
If the bundle command is not found, your PATH is not set correctly. You might need to PermitUserEnvironment in the sshd running on that host. Then you can set the path manually in the deploy user's .ssh/environment file.
Is bundler installed on the remote machine?
Somewhere in your log it says:
Could not find bundler (>= 0)
The problem may be that you need to create the bundler wrapper. You can do that this way(in your deploy.rb, for example)
require "rvm/capistrano" # http://beginrescueend.com/integration/capistrano/
# rvm-capistrano settings
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
namespace :rvm do
task :create_bundle_wrapper, roles: :app do
run "rvm wrapper #{rvm_ruby_string} bundle bundle"
end
end
after "deploy:create_symlink", "rvm:create_bundle_wrapper"
Related
I am installing app from my private git repository. I installed all dependencies and I am using Capistrano.I am able to run app successfully on my local machine.I am using rails -v 3.2.14 and ruby -v ruby 1.9.3p362 and linux server
when I am running cap production deploy I am getting error
......
....
sftp upload complete
* executing "cd /var/www/vhosts/..../apps/login/current && bundle exec thin -C /var/www/vhosts/....../apps/login/current/thin.yml -O restart"
servers: ["......net"]
[root#emerge126.mysitehosting.net] executing command
** [out :: root#........net] Stopping server on 127.0.0.1:8080 ...
** [out :: root#........net] /var/www/vhosts/......./apps/.../shared/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/daemonizing.rb:131:in 'send_signal': Can't stop process, no PID found in tmp/pids/thin.8080.pid (Thin::PidFileNotFound)
My deploy.rb file require
'bundler/capistrano'
require 'capistrano/ext/multistage'
require 'capistrano-thin'
set :stages, ["staging", "production"]
set :default_stage, "production"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :ssh_options, {
config: false
}
set :application, "myapp"
set :repository, "https://........git"
set :scm, :git
set :deploy_via, :remote_cache
set :branch, 'master'
set :deploy_to, "/var/www/vhosts/......../apps/#{application}"
set :keep_releases, 5
set :use_sudo, false
set :thin_servers, 1
set :thin_port, 8081
namespace :deploy do
namespace :db do
desc "Seed the database"
task :seed, :roles => :db do
# on_rollback { deploy.db.restore }
run_remote_rake('db:seed')
end
end
task :symlink_configs do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/config/auth.yml #{current_path}/config/auth.yml"
end
end
before "deploy:restart", "deploy:symlink_configs"
after "deploy:update", "deploy:cleanup"
def run_remote(cmd)
run "cd #{current_path} && #{cmd}"
end
def run_remote_rake(task)
rails_env = fetch(:rails_env, 'integration')
run_remote("rake #{task} RAILS_ENV=#{rails_env}")
end
My production.rb file
set :deploy_to, "/var/www/vhosts/....../apps/# {application}"
server 'root#.......net', :web, :app, :db, :primary => true
set :thin_port, 8081
set :rails_env, 'production'
I need some help. Its a multi rails app server. Please ask any more info if you need. I have also replaced site and github url with .... because of site security.
There is no thin process running on your server, that's why you're getting the Can't stop process, no PID found error. I suggest starting thin manually so your deploy script can then successfully restart it.
Here is my deploy.rb
require "bundler/capistrano"
set :rvm_ruby_string, "ruby-2.0.0-p247"
set :rvm_type, :user
set :application, "myapp"
set :repository, "git#bitbucket.org:user/myapp.git"
set :user, "my-server-username-ssh"
set :branch, "master"
set :deploy_to, "/var/rails_apps/myapp" # I have current, release and shared directory here
set :deploy_via, :copy
set :use_sudo, true
set :rvm_install_with_sudo, true
default_run_options[:pty] = true
set :port, 1234
set :scm, :git
role :web, "myapp.com"
role :app, "myapp.com"
role :db, "myapp.com", :primary => true
role :db, "myapp.com"
after "deploy:update_code","deploy:config_symlink"
set :rvm_type, :system
# 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
task :config_symlink do
#run "cp #{release_path}/config/database.yml.example #{release_path}/config/database.yml"
end
desc 'Re-establish database.yml'
task :set_database_symlink do
run "rm -fr #{current_path}/config/database.yml && cd #{current_path}/config &&
ln -nfs #{shared_path}/database.yml database.yml"
end
end
before 'deploy', 'rvm:install_ruby'
before 'deploy', 'rvm:create_gemset'
require "rvm/capistrano"
if i run cap deploy:migrate
I am getting error no database found error.
And when i manually run rake db:create in my server I am facing this error
/usr/local/rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find multi_json-1.8.0 in any of the sources (Bundler::GemNotFound)
How can i create and migrate my database.
Edit-1
Even i have updated my certificate using
rvm osx-ssl-certs update all
In my gem list i can fine
multi_json (1.8.2)
I already had this gem installed but I need to
bundle update multi_json
Seems like you might have requirements for multiple versions of the multi_json gem. You can try specifying the gem version like:
gem 'multi_json', '1.8.0'
Rerun the bundle command locally and checkin your Gemfile.lock before you deploy.
I'm trying to deploy my first app to a VPS ubuntu 12.10, using capsitrano, and following the RailsCasts "Deploying to a VPS" videocast.
One more question, i haven't added an nginx config, nor a unicorn config file. Can i go without them? ( I will want to config nginx trough console.)
My deploy.rb file
require "bundler/capistrano"
set :application, "picurwebaruhaz"
set :scm, "git"
set :repository, "git://github.com/gwuix2/picurwebaruhaz.git"
set :branch, "master"
set :user, "gwuix2"
set :deploy_to, "/home/#{user}/#{application}"
default_run_options[:pty] = true
# 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, "198.211.117.84" # Your HTTP server, Apache/etc
role :app, "198.211.117.84" # This may be the same as your `Web` server
role :db, "198.211.117.84", :primary => true # This is where Rails migrations will run
role :db, "198.211.117.84"
# 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
I get the following error:
* executing "cd /home/gwuix2/picurwebaruhaz/releases/20130322113243 && bundle install --gemfile /home/gwuix2/picurwebaruhaz/releases/20130322113243/Gemfile --path /home/gwuix2/picurwebaruhaz/shared/bundle --deployment --quiet --without development test"
servers: ["198.211.117.84"]
[198.211.117.84] executing command
** [out :: 198.211.117.84] sh: 1: bundle: not found
command finished in 357ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/gwuix2/picurwebaruhaz/releases/20130322113243; true"
servers: ["198.211.117.84"]
[198.211.117.84] executing command
command finished in 384ms
failed: "sh -c 'cd /home/gwuix2/picurwebaruhaz/releases/20130322113243 && bundle install --gemfile /home/gwuix2/picurwebaruhaz/releases/20130322113243/Gemfile --path /home/gwuix2/picurwebaruhaz/shared/bundle --deployment --quiet --without development test'" on 198.211.117.84
Edit:
Here is my app:
APP ON GITHUB https://github.com/gwuix2/picurwebaruhaz
Edit_2:
If I SSH into the server and run $ gem install bundler, it installs, but when I run:
gwuix2#picurbolt:~$ sudo gem install bundler sudo: gem: command not
found
any suggestions?
Can't figure it out myself.
deploy.rb needs:
require "rvm/capistrano"
require "bundler/capistrano"
Try running bundler command without sudo:
gwuix2#picurbolt:~$ gem install bundler sudo: gem: command not found
i've a problem with the deploying.
i have a ubuntu 11.10 server, i have installed ruby 1.9.2 and rails 3.2.6 with RVM.
i have yet made the pull of my git, it's located in /home/**/idepro.git
i runned the "capify ." command and i modify the deploy.rb file.
i haven't any problem when i run the commands "cap deploy:setup" and "cap deploy:check", but when i run "cap deploy" i have a problem with the enviorment path. The error is:
** [out :: 176.58.****] /usr/bin/env: ruby
** [out :: 176.58.****] : No such file or directory
these are the ror's path:
******#******:~$ which ruby
/home/******/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
and this is the value of $PATH:
******#******:~$ echo $PATH
/home/******/.rvm/gems/ruby-1.9.2-p320/bin:/home/******/.rvm/gems/ruby-1.9.2-p320#global/bin:/home/******/.rvm/rubies/ruby-1.9.2-p320/bin:/home/******/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/******/.rvm/gems/ruby-1.9.2-p320/bin
This is my deploy.rb file:
# RVM bootstrap
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
#require 'rvm/capistrano'
set :rvm_ruby_string, 'ruby1.9.2-p290'
# bundler bootstrap
require 'bundler/capistrano'
# main details
set :application, "176.58.******"
role :web, "176.58.******"
role :app, "176.58.******"
role :db, "176.58.******", :primary => true
ssh_options[:port] = ******
set :user, "******"
set :password, "******"
# server details
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :deploy_to, "/var/www/idealarm2"
set :deploy_via, :remote_cache
set :user, "passenger"
set :use_sudo, false
# repo details
set :scm, :git
set :scm_username, "passenger"
set :repository, "/home/******/idepro.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
#default_environment['PATH']='/home/******/.rvm/gems/ruby-1.9.2-p320/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin/:/usr/bin:/bin'
#default_environment['GEM_PATH']='/home/******/.rvm/gems/ruby-1.9.2-p320:/home/******/.rvm/gems/ruby-1.9.2-p320#global:/usr/lib/ruby/gems/1.$
Could anyone help me with the PATH configuration?
I'm using capistrano with RVM with no issues, having followed the 'Integration via the rvm-capistrano gem' section instructions at https://rvm.io//integration/capistrano/.
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/