Deploying Capistrano Using Thin Servers

played with Capistrano to get automatic deployment between my server and my development machine. I almost configured it, except that Capistrano does not seem to be able to start my servers using the execle bundle command. I always get the following error:

EDIT: The configuration file is now located in /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 copy the last section that matters. Full copy of files, etc. It works great. This is just the beginning of a cluster that seems to be failing. Here is my deploy.rb file that processes all Capistrano materials:

EDIT: The file has been changed 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: Now, the following problems occur:

  • I get the message "Unable to find the GemFile error" when I run the close shell command from my system in the last step: loading the servers

  • Migrations not performed

  • I can no longer start the cluster manually. Only one tone thin starts.

UPDATE: Here are the gem env settings from the server on which I am deploying. This information was obtained using the shell shell and the subsequent launch of 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/
+4
source share
2 answers

Finally, I solved the problem ... First, in order for the application to play perfectly with the environment server, the following script does what it should do:

 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 move well into the required deployment structures and execute the commands necessary to control the thin process. The problem was that the cd command did not execute when run as sudo. The reason is that cv exists only in the shell and is not a well-known sudo command.

The second problem was the subtle configuration. Since thin.yml was a small type, thin servers could not be started. The script below starts a cluster of 4 thin servers 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 
+10
source

Man, find out where GEM_HOME or GEM_PATH points. It must be.

-2
source

All Articles