title: Capistrano deploy with thin servers
body: <p>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:</p>
  
  <p><strong>EDIT: The config file now resides at /var/www/apps/current/thin.yml</strong></p>
  
  <pre>
  ...
    * 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
  </pre>
  
  <p>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:</p>
  
  <p>EDIT: The file has been modified to the following:</p>
  
  <pre><code>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 =&gt; 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 =&gt; {:no_release =&gt; 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"
  </code></pre>
  
  <p><strong>EDIT: This is my thin.yml file</strong></p>
  
  <pre class="lang-yaml prettyprint-override"><code>---
  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
  </code></pre>
  
  <p><strong>EDIT:</strong>
  The following problems are occurring now:</p>
  
  <ol>
  <li><p>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</p></li>
  <li><p>Migrations are not performed</p></li>
  <li><p>I can't seem to fire up the cluster manually either anymore. Only one instance of thin is starting up.</p></li>
  </ol>
  
  <p><em><strong>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:</em></strong></p>
  
  <pre>
  ====================================================================
  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/
  </pre>