Here is the part of message from cap deploy:
** [out :: 176.195.225.93] /home/cj/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `
to_specs': Could not find bundler (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2,
rdoc-3.9.4] (Gem::LoadError)
** [out :: 176.195.225.93] from /home/cj/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256
:in `to_spec'
** [out :: 176.195.225.93] from /home/cj/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
** [out :: 176.195.225.93] from /home/cj/.rvm/gems/ruby-1.9.3-p125/bin//bundle:18:in `<main>'
command finished in 143ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/byop/releases/20120302043344; true"
servers: ["176.195.225.93"]
[176.195.225.93] executing command
command finished in 131ms
failed: "env PATH=/home/cj/.rvm/gems/ruby-1.9.3-p125/bin/:$PATH BUNDLE_PATH=/home/cj/.rvm/gems/ruby-1.9.3-p125/bin/
sh -c 'cd /var/www/byop/releases/20120302043344 && bundle install --gemfile /var/www/byop/releases/20120302043344/Gemfile --
path /var/www/byop/shared/bundle --deployment --quiet --without development test'" on 176.195.225.93
There are a few posts for the same issue and none of the solution worked. We set default in deploy.rb like:
set :default_environment, {
'PATH' => "/home/cj/.rvm/gems/ruby-1.9.3-p125/bin/:$PATH",
'BUNDLE_PATH' => '/home/cj/.rvm/gems/ruby-1.9.3-p125/bin/'
}
But the cap still have problem finding bundle.
Any help is appreciated. Thanks so much.
UPDATE:
here is the output of bundle -v under /var/www/byop:
Bundler version 1.0.22
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 can't deploy my Rails 4 app with strange error on assets:precompile. It's seems like task can't use installed gems.
In development and production environment on local machine all works perfectly. Part of deploy log:
INFO[286bfe45] Running ~/.rvm/bin/rvm 2.2.0#gemset do bundle install --binstubs /var/www/app/shared/bin --path /var/www/app/shared/bundle --without development test --deployment --quiet on app.com
DEBUG[286bfe45] Command: cd /var/www/app/releases/20150411140229 && ~/.rvm/bin/rvm 2.2.0#gemset do bundle install --binstubs /var/www/app/shared/bin --path /var/www/app/shared/bundle --without development test --deployment --quiet
INFO[286bfe45] Finished in 2.512 seconds with exit status 0 (successful).
DEBUG[6abacc25] Running /usr/bin/env if test ! -d /var/www/app/releases/20150411140229; then echo "Directory does not exist '/var/www/app/releases/20150411140229'" 1>&2; false; fi on app.com
DEBUG[6abacc25] Command: if test ! -d /var/www/app/releases/20150411140229; then echo "Directory does not exist '/var/www/app/releases/20150411140229'" 1>&2; false; fi
DEBUG[6abacc25] Finished in 0.252 seconds with exit status 0 (successful).
INFO[6a11bfd6] Finished in 1.650 seconds with exit status 0 (successful).
DEBUG[9a60b6ea] Running /usr/bin/env if test ! -d /var/www/app/releases/20150411140229; then echo "Directory does not exist '/var/www/app/releases/20150411140229'" 1>&2; false; fi on app.com
DEBUG[9a60b6ea] Command: if test ! -d /var/www/app/releases/20150411140229; then echo "Directory does not exist '/var/www/app/releases/20150411140229'" 1>&2; false; fi
DEBUG[9a60b6ea] Finished in 0.252 seconds with exit status 0 (successful).
INFO[926b14e1] Running ~/.rvm/bin/rvm 2.2.0#gemset do bundle exec rake assets:precompile on app.com
DEBUG[926b14e1] Command: cd /var/www/app/releases/20150411140229 && ( RAILS_ENV=production ~/.rvm/bin/rvm 2.2.0#gemset do bundle exec rake assets:precompile )
DEBUG[926b14e1] I, [2015-04-11T14:02:51.203678 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/apple-touch-icon-114x114-precomposed-305f00ea8c7d006b84bb4fae81f9560f.png
DEBUG[926b14e1] I, [2015-04-11T14:02:51.230319 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/projects/project-item-engine-rails-879f2b31347734136f7381f19bb9f6a3.png
DEBUG[926b14e1] I, [2015-04-11T14:02:51.233698 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/projects/projects-list-header-57d1dcc1cc60e2eb39438cb1845a9aa2.jpg
DEBUG[926b14e1] I, [2015-04-11T14:02:51.236956 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/rails-31b23f13156504238438fdd89afe6fd6.png
DEBUG[926b14e1] I, [2015-04-11T14:02:51.237889 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/sprites/blog-color-fd3e21aa29714c4881b34b34b4980ba9.png
DEBUG[926b14e1] I, [2015-04-11T14:02:51.284081 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/application-659c280b13b0f592813748b6abb50b74.js
DEBUG[926b14e1] I, [2015-04-11T14:02:51.311349 #18205] INFO -- : Writing /var/www/app/releases/20150411140229/public/assets/front-9b21c4b4182f885f99929c6f71639a44.js
DEBUG[926b14e1] rake aborted!
DEBUG[926b14e1] Sass::SyntaxError: Undefined mixin 'sprites-sprite'.
DEBUG[926b14e1] (in /var/www/app/releases/20150411140229/app/assets/stylesheets/static.css.scss:96)
DEBUG[926b14e1] /var/www/app/releases/20150411140229/app/assets/stylesheets/static.css.scss:96:in `sprites-sprite'
DEBUG[926b14e1] /var/www/app/releases/20150411140229/app/assets/stylesheets/static.css.scss:96
DEBUG[926b14e1] /var/www/app/shared/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:253:in `visit_mixin'
DEBUG[926b14e1] /var/www/app/shared/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `visit'
I think that problem is in placing gems. First line of log telling me that all gems in /var/www/app/shared/bundle and it's truth — they are really there. But if I run rvm 2.2.0#gemset do gem list as deploy user I don't see installed gems in list:
deployer#server:/var/www/app/current$ rvm 2.2.0#gemset do gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundler (1.8.4)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
power_assert (0.2.2)
psych (2.0.8)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.8)
And when I run bundle from app's folder I can see a full list of installed gems:
deployer#server:/var/www/app/current$ bundle
Using rake 10.4.2
Using sass 3.2.19
Using bootstrap-sass 3.1.1.1
Using compass 0.12.7
Using breakpoint 2.0.7
Using compass-rails 2.0.0
Using sprockets 2.11.0
Using sprockets-rails 2.2.2
/* removed some lines to save space */
Using rails 4.1.8
Using sass-rails 4.0.3
Using uglifier 2.5.0
Using unicorn 4.8.3
Bundle complete! 39 Gemfile dependencies, 87 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into /var/www/app/shared/bundle.
I use rvm for development and production in single-user mode and some my files here:
# deploy.rb
lock '3.2.1'
set :application, 'App'
set :repo_url, 'git#bitbucket.org:app/app.com.git'
set :deploy_to, '/var/www/app'
set :rvm_ruby_version, '2.2.0#gemset'
set :unicorn_env, 'production'
set :rails_env, :production
set :linked_files, %w{config/database.yml config/secrets.yml config/scp.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
invoke 'unicorn:restart'
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
after :publishing, :restart
end
Capfile
# Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano3/unicorn'
require 'whenever/capistrano'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
Front.css.scss set as precompiled in application.rb
# front.css.scss
#import "compass";
#import "compass/utilities/sprites";
#import "sprites/*.png";
#include all-sprites-sprites;
#import "breakpoint";
$breakpoint-tiny : 0 660px;
#import "static";
And for example static.css.scss:
/* static.css.scss */
.blog {
#include sprites-sprite(blog-gray);
&:hover {
#include sprites-sprite(blog-color);
}
}
If I remove all mixins from static.css.scss deploy will finished successfully.
I solved the problem, it wasn't related to capistrano or even rvm.
I use two layouts for my app: front.html.slim and admin.html.slim, each with a dedicated stylesheet: front.css and admin.css.
In front.css.scss I was using the following (sass) syntax:
#import "compass";
#import "compass/utilities/sprites";
While admin.css.scss used Sprocket's syntax:
/*
*= require base
*= require posts
*= require projects
The assets:precompile task finished successfully after I changed admin.css.scss to actual sass syntax:
#import "base";
#import "posts";
#import "projects";
Thanx #RAJ for your advice.
I just ran rake db:migrate directly on my server with no problems:
$ pwd
/var/www/vhosts/example.com/current
$ rake db:migrate
Then i tried to run it via a capistrano task and i get an error. The task and output are below. Why does rake db:migrate not work via my capistrano task?
task
namespace :deploy do
# run the db migrations
task :run_migrations, :roles => :db do
puts "RUNNING DB MIGRATIONS"
run "cd #{current_path}; rake db:migrate RAILS_ENV=#{rails_env}"
end
end
cap deploy:run_migrations
$ cap deploy:run_migrations
* executing `deploy:run_migrations'
RUNNING DB MIGRATIONS
* executing "cd /var/www/vhosts/example.com/current; rake db:migrate"
servers: ["example.com"]
[example.com] executing command
** [out :: example.com] (in /var/www/vhosts/example.com/releases/20121122011144)
** [out :: example.com] rake aborted!
** [out :: example.com] no such file to load -- rubygems
** [out :: example.com] /var/www/vhosts/example.com/releases/20121122011144/Rakefile:5:in `require'
** [out :: example.com] (See full trace by running task with --trace)
command finished in 390ms
failed: "sh -c 'cd /var/www/vhosts/example.com/current; rake db:migrate'" on example.com
EDIT
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p125/bin/ruby
$ which rails
/usr/local/rvm/gems/ruby-1.9.3-p125/bin/rails
EDIT
When i added --trace to the db migrations, it looks like it's using /usr/lib/ruby/site_ruby/1.8/rake.rb, but from the looks of this:
$ which rake
/usr/local/rvm/gems/ruby-1.9.3-p125/bin/rake
i would have expected it to use rake at /usr/local/rvm/gems/ruby-1.9.3-p125/bin/rake rather than /usr/lib/ruby/site_ruby/1.8/rake.rb.
cap deploy's output from the deploy:run_migrations task
* executing `deploy:run_migrations'
RUNNING DB MIGRATIONS
* executing "cd /var/www/vhosts/example.com/current; rake db:migrate RAILS_ENV=production --trace"
servers: ["example.com"]
[example.com] executing command
** [out :: example.com] (in /var/www/vhosts/example.com/releases/20121123184358)
** [out :: example.com] rake aborted!
** [out :: example.com] no such file to load -- rubygems
** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/boot.rb:1:in `require'
** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/boot.rb:1
** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/application.rb:1:in `require'
** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/config/application.rb:1
** [out :: example.com] /var/www/vhosts/example.com/releases/20121123184358/Rakefile:5:in `require'
** [out :: example.com] /var/www/vhosts/famnfo.com/releases/20121123184358/Rakefile:5
** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1828:in `load'
** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1828:in `load_rakefile'
** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rake.rb:1900:in `run'
** [out :: example.com] /usr/bin/rake:8
command finished in 422ms
failed: "sh -c 'cd /var/www/vhosts/example.com/current; rake db:migrate RAILS_ENV=production --trace'" on example.com
EDIT
output after adding #Super Engineers code
* executing `bundle:install'
* executing "ls -x /var/www/vhosts/example.com/releases"
servers: ["example.com"]
[example.com] executing command
command finished in 572ms
* executing "cd /var/www/vhosts/example.com/releases/20121124160218 && bundle install --gemfile /var/www/vhosts/example.com/releases/20121124160218/Gemfile --path /var/www/vhosts/example.com/shared/bundle --deployment --quiet --without development test"
servers: ["example.com"]
[example.com] executing command
** [out :: example.com] You are trying to install in deployment mode after changing
** [out :: example.com] your Gemfile. Run `bundle install` elsewhere and add the
** [out :: example.com] updated Gemfile.lock to version control.
** [out :: example.com]
** [out :: example.com] You have added to the Gemfile:
** [out :: example.com] * mysql2
** [out :: example.com] * therubyracer
** [out :: example.com] * rvm-capistrano
** [out :: example.com] * passenger
** [out :: example.com]
** [out :: example.com] You have deleted from the Gemfile:
** [out :: example.com] * mysql
command finished in 999ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/vhosts/example.com/releases/20121124160218; true"
servers: ["example.com"]
[example.com] executing command
command finished in 826ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p125' -c 'cd /var/www/vhosts/example.com/releases/20121124160218 && bundle install --gemfile /var/www/vhosts/example.com/releases/20121124160218/Gemfile --path /var/www/vhosts/example.com/shared/bundle --deployment --quiet --without development test'" on example.com
EDIT
Entire deploy.rb file
require 'bundler/capistrano'
require 'rvm/capistrano'
# set environment
set :rails_env, "production"
# set the ruby version
set :rvm_ruby_string, 'ruby-1.9.3-p125'
set :rvm_type, 'webadmin'
# server username and password
set :user, 'super'
set :password, 'secret'
# subversion repo username and password
set :scm, :subversion
set :scm_username, "super"
set :scm_password, 'secret'
set :svnserver, "myreposerver"
set :repository, "myrepo"
# project info
set :server, ''
set :application, "FamNFo"
set :applicationdir, '/Volumes/Macintosh HD/Users/myname/Sites/example'
role :web, "example.com"
role :app, "example.com"
role :db, "example.com", :primary => true
set :use_sudo, true
# database config
#set :migrate_env, "#{rails_env}"
# specify the rvm type. We just want to use the system wide one since we're not currently specifying gemsets for each project
set :rvm_type, :system
# where to put the files
set :deploy_to, "/var/www/vhosts/example.com"
# fixes the "sorry, you must have a tty to run sudo" issue
default_run_options[:pty] = true
# precompiles the assets
load 'deploy/assets'
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
# restart the server
task :restart, :roles => :app do
run "/etc/init.d/http restart graceful"
end
# chmod the files
task :after_update_code, :roles => [:web, :db, :app] do
run "chmod 755 #{release_path}/public -R"
end
# install new gems
desc "run bundle install and ensure all gem requirements are met"
task :install do
run "cd #{current_path} && bundle install --without=test --no-update-sources --trace"
end
# run the db migrations
task :run_migrations, :roles => :db do
puts "RUNNING DB MIGRATIONS"
run "cd #{current_path}; rake db:migrate RAILS_ENV=#{rails_env} --trace"
end
# precompile assets
task :precompile_assets do
run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=#{rails_env}"
end
task :start do ; end
task :stop do ; end
# restart the server
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{sudo} /etc/init.d/httpd restart graceful"
end
end
# hook to run db migrations after code update
after("deploy:update", "deploy:run_migrations")
#after("deploy:update", "deploy:precompile_assets")
after "deploy:update", "deploy:install"
# if you want to clean up old releases on each deploy uncomment this:
after "deploy:restart", "deploy:cleanup" # leave the last 5 releases only
Its because of ruby conflict. I've faced same error. You will need to use rvm/capistrano gem. I'll paste some code from my cap file which will give you some idea about how to set the ruby version while deploying.
install the gem
gem install rvm-capistrano
in you deploy.rb file add these lines
require 'bundler/capistrano'
require 'rvm/capistrano'
set :rvm_ruby_string, "ruby-1.9.3-p125"
set :rvm_type, 'webadmin'
For more information you can visit this link rvm/capistrano
The relevant error here seems to be no such file to load -- rubygems.
Quite likely it is because of multiple ruby installations on the production server.
Check out this previous solution for a similar problem : https://stackoverflow.com/a/2896596/429758
Also, this thread on the capistrano mailing list is helpful: https://groups.google.com/forum/?fromgroups=#!topic/capistrano/JzVPRbQclY4
Are you using rvm/capistrano? With that you can specify the ruby version that you want to use on the server in your capistrano recipes. I suspect that when you run capistrano it's not using your rvm setup, when you login and run the rake task, your user is setup to use the rvm ruby version.
I'm deploying my Rails 3.2.2, Ruby 1.9.3 app with Capistrano to a Linux server. When I'm running a cap deploy I get this error:
* executing `deploy:assets:precompile'
* executing "cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["example.com"]
[example.com] executing command
[example.com] sh -c 'cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: example.com] rake aborted!
** [out :: example.com] cannot load such file -- ruby-debug
** [out :: example.com]
** [out :: example.com] (See full trace by running task with --trace)
command finished in 8962ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/production/releases/20120418090209; true"
servers: ["example.com"]
[example.com] executing command
[example.com] sh -c 'rm -rf /var/www/production/releases/20120418090209; true'
command finished in 176ms
failed: "sh -c 'cd /var/www/production/releases/20120418090209 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on example.com
It says, that the ruby-debug gem was not found. But ruby-debug is not inside the production group in my Gemfile:
group :development, :test do
gem "steak"
gem "linecache19", :git => "git://github.com/mark-moseley/linecache", :require => "ruby-debug"
gem "ruby-debug-base19x", "~> 0.11.30.pre4"
gem "ruby-debug19"
gem "rails_best_practices"
gem "ruby_parser"
gem "reek"
gem "flog"
gem "jslint_on_rails", :git => "git://github.com/psionides/jslint_on_rails"
gem "jasmine-rails"
end
Cause the error gets thrown after the rake assets:precompile command, I think it has something todo with Capistrano and the load 'deploy/assets' call inside my Capfile:
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['config/deploy/recipes/*.rb','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
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
When I remove this line, everything deploys fine, but (of course) the assets aren't found in production. And, if I run bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile directly on the server (inside the app dir) I get the same error.
So what should I do?
ruby-debug is obsolete. In ruby >= 1.9 you should use excellent debugger gem
see: https://github.com/cldwalker/debugger and http://railscasts.com/episodes/54-debugging-ruby-revised
I'm deploying to a Debian 6 server, with Apache, Passenger, Ruby1.9.1
When I run "cap deploy" or "cap deploy:migrations" I get this error:
[out :: ip.address] Could not find multi_json-1.0.3 in any of the sources
** [out :: ip.address] Run `bundle install` to install missing gems.
** [out :: ip.address]
command finished in 1037ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/releases/20111208004427; true"
servers: ["ip.address"]
[ip.address] executing command
command finished in 489ms
failed: "sh -c 'cd /var/www/releases/20111208004427 && /usr/bin/rake1.9.1 RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on ip.address
Note the run bundle install to install missing gems and failed sh -c ... part.
I already tried this export PATH=/var/lib/gems/1.9.1/bin:${PATH} and tried many other possible solutions but nothing seems to work.
By the way, NO rvm.
Make sure that your config/deploy.rb file is including Bundler's capistrano tasks with this line:
require 'bundler/capistrano'
This will tell it to run bundle install after updating your code, but before it runs other tasks like rake assets:precompile.
For reference for everybody else getting the same error. Found answer: http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/
been playing around with Capistrano to get an automated deploy between my server and my development machine. I've almost got it configured except that Capistrano doesn't seem to be able to start up my servers using the bundle exec command. I'm always receiving the following error:
EDIT: The config file now resides at /var/www/apps/current/thin.yml
...
* executing "sudo -p 'sudo password: ' bundle exec thin start -C /var/www/thin.config.yml"
servers: ["85.255.206.157"]
[85.255.206.157] executing command
** [out :: 85.255.206.157] Could not locate Gemfile
command finished in 216ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' bundle exec thin start -C /var/www/thin.config.yml'" on 85.255.206.157
Only copied the last section that's relevant. The whole copying of the files etc works fine. It's just starting the cluster that seems to be failing.
Here is my deploy.rb file that handles all Capistrano stuff:
EDIT: The file has been modified to the following:
require "bundler/capistrano"
# define the application and Version Control settings
set :application, "ESCO Matching Demo"
set :repository, "svn://192.168.33.70/RubyOnRails/ESCO"
set :deploy_via, :copy
# Set the login credentials for Capistrano
set :user, "kurt"
# Tell Capistrano where to deploy
set :deploy_to, "/var/www/apps"
# Tell Capistrano the servers it can play with
server "85.255.206.157", :app, :web, :db, :primary => true
# Generate an additional task to fire up the thin clusters
namespace :deploy do
desc "Start the Thin processes"
task :start do
sudo "bundle exec thin start -C thin.yml"
end
desc "Stop the Thin processes"
task :stop do
sudo "bundle exec thin stop -C thin.yml"
end
desc "Restart the Thin processes"
task :restart do
sudo "bundle exec thin restart -C thin.yml"
end
desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder"
task :update_cv_assets, :except => {:no_release => true} do
run "ln -s #{shared_path}/cvs #{latest_release}/public/cvs"
end
end
# Define all the tasks that need to be running manually after Capistrano is finished.
after "deploy:finalize_update", "deploy:update_cv_assets"
after "deploy", "deploy:migrate"
EDIT: This is my thin.yml file
---
pid: tmp/pids/thin.pid
address: 0.0.0.0
timeout: 30
wait: 30
port: 4000
log: log/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
server: 4
daemonize: true
chdir: /var/www/apps/current
EDIT:
The following problems are occurring now:
I'm receiving the Cannot find GemFile error when running the cap deploy command from my system on the final step : the booting of the servers
Migrations are not performed
I can't seem to fire up the cluster manually either anymore. Only one instance of thin is starting up.
UPDATE:
Here is the gem env settings from the server I'm deploying to. This information is obtained by using the cap shell and then running the commands:
====================================================================
Welcome to the interactive Capistrano shell! This is an experimental
feature, and is liable to change in future releases. Type 'help' for
a summary of how to use the shell.
--------------------------------------------------------------------
cap> echo $PATH
[establishing connection(s) to 85.255.206.157]
Password:
** [out :: 85.255.206.157] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
cap> gem env
** [out :: 85.255.206.157] RubyGems Environment:
** [out :: 85.255.206.157] - RUBYGEMS VERSION: 1.3.6
** [out :: 85.255.206.157] - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
** [out :: 85.255.206.157] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
** [out :: 85.255.206.157] - RUBY EXECUTABLE: /usr/bin/ruby1.8
** [out :: 85.255.206.157] - EXECUTABLE DIRECTORY: /usr/bin
** [out :: 85.255.206.157] - RUBYGEMS PLATFORMS:
** [out :: 85.255.206.157] - ruby
** [out :: 85.255.206.157] - x86_64-linux
** [out :: 85.255.206.157] - GEM PATHS:
** [out :: 85.255.206.157] - /usr/lib/ruby/gems/1.8
** [out :: 85.255.206.157] - /home/kurt/.gem/ruby/1.8
** [out :: 85.255.206.157] - GEM CONFIGURATION:
** [out :: 85.255.206.157] - :update_sources => true
** [out :: 85.255.206.157] - :verbose => true
** [out :: 85.255.206.157] - :benchmark => false
** [out :: 85.255.206.157] - :backtrace => false
** [out :: 85.255.206.157] - :bulk_threshold => 1000
** [out :: 85.255.206.157] - REMOTE SOURCES:
** [out :: 85.255.206.157] - http://rubygems.org/
Finally solved the problem...
First in order to get the bundle application to play nicely with the environemnt server, the following script does what it's supposed to be doing:
require "bundler/capistrano"
default_run_options[:pty] = true
# define the application and Version Control settings
set :application, "ESCO Matching Demo"
set :repository, "svn://192.168.33.70/RubyOnRails/ESCO"
set :deploy_via, :copy
set :user, "kurt"
set :deploy_to, "/var/www/apps"
# Tell Capistrano the servers it can play with
server "85.255.206.157", :app, :web, :db, :primary => true
# Generate an additional task to fire up the thin clusters
namespace :deploy do
desc "Start the Thin processes"
task :start do
run <<-CMD
cd /var/www/apps/current; bundle exec thin start -C config/thin.yml
CMD
end
desc "Stop the Thin processes"
task :stop do
run <<-CMD
cd /var/www/apps/current; bundle exec thin stop -C config/thin.yml
CMD
end
desc "Restart the Thin processes"
task :restart do
run <<-CMD
cd /var/www/apps/current; bundle exec thin restart -C config/thin.yml
CMD
end
desc "Create a symlink from the public/cvs folder to the shared/system/cvs folder"
task :update_cv_assets, :except => {:no_release => true} do
run <<-CMD
ln -s /var/www/shared/cvs /var/www/apps/current/public
CMD
end
end
# Define all the tasks that need to be running manually after Capistrano is finished.
after "deploy:finalize_update", "deploy:update_cv_assets"
after "deploy", "deploy:migrate"
This script can navigate nicely into the required deployment structures and execute the commands needed to control the Thin process. The problem was that the cd command was not done when running these as sudo. The reason behind this is that cv exist only in the shell and is not a known command to sudo.
The second problem was the thin configuration. Because there was a small type on the thin.yml the thin servers could not be started up. The script below fires up a cluster of 4 thin server running on port 4000 -> 4003.
---
pid: tmp/pids/thin.pid
address: 0.0.0.0
timeout: 30
wait: 30
port: 4000
log: log/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
chdir: /var/www/apps/current
Man, find out where is GEM_HOME or GEM_PATH is pointing. Must be it.