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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With