I just finished migrating my deploy script from Capistrano 1.4.1 and
Deprec 1.9.2 combo to Capistrano 2.5.0 with a lot of help from Lee
(thank you sir).  It is working great.  However, there is one thing
that I do not understand.  It always gives this line of error message
when I run it initially with seemingly no ill effect.  Every
subsequent run is clean until I have to type in the password again.
Here is a snippet of Capistrano session:

[EMAIL PROTECTED]:~/work/vjc-comp$ RAILS_ENV=staging cap
deploy
  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    triggering before callbacks for `deploy:update_code'
  * executing `deploy:do_sudo'
  * executing "sudo -p 'sudo password: ' date"
    servers: ["staging.virtualjobcoach.com"]
    [staging.virtualjobcoach.com] executing command
Password:
*** [err :: staging.virtualjobcoach.com]   <--- this line is where the
error shows up
 ** [out :: staging.virtualjobcoach.com] Wed Oct 29 02:21:58 UTC 2008
    command finished
  * executing "svn checkout -q  -r1923
https://secure.svnrepository.com/xxxt/yyy/branches/20081027-companies /
var/www/apps/isabont/releases/20081029022203 && (echo
..............................................

Here is the deploy.rb script with domain names and svn server names
hidden:

# Determine rails environment, get it from RAILS_ENV variable
set :rails_env, ENV["RAILS_ENV"] || "development"
case rails_env
  when "production"
    set :domain, "aaa"
  when "staging"
    set :domain, "bbb"
  when "test"
    set :domain, "10.211.550.100"
  when "acsol_production"
    set :domain, "ccc"
  when "acsol_staging"
    set :domain, "ddd"
  else
    raise "No deployment defined for environment #{rails_env}"
end
# Define roles, these are common across all servers
role :web, domain
role :app, domain
role :db,  domain, :primary => true

#  --- These variables are needed for setting up Capistrano run-time
so that
#  --- each release instance can be deployed.
#  ------------------ REQUIRED VARIABLES
-------------------------------------
set :application, "isabont"
set :deploy_to, "/var/www/apps/#{application}"
set :user, "deploy"
#set :repository, "https://secure.svnrepository.com/xxx/yyy/trunk";
set :repository, "https://secure.svnrepository.com/xxx/yyy/branches/
20081027-companies"

# ------------------- SYMLINK VARIABLES
--------------------------------------
# Symlink these dirs to shared
set :app_symlink_dirs, %w(tmp/openoffice tmp/pids public/flash public/
pages)

# Directory for user uploaded files - Users are allowed to store their
docs on
# our servers under /var/www/apps/isabont/shared/files directory
set :app_upload_dir, "files"

# ----------- MONGREL VARIABLES WORK WITH APACHE PROXY
----------------------
set :mongrel_servers, 4
set :mongrel_address, "127.0.0.1"
set :mongrel_environment, rails_env
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.yml"

# ------------------ OPEN OFFICE SET-UP VARIABLE
----------------------------
# -- These are only needed for Open Office Configuration
--------------------
set :ooo_resource_dir, "resources/open_office"
set :ooo_script_dir, lambda {"/home/#{user}/.openoffice.org2/user/
basic/Standard"}
set :ooo_bin, "/usr/lib/openoffice/program/soffice" # ubuntu path

# ------------------ CALLBACKS
----------------------------------------------
before "deploy:update_code", "deploy:do_sudo"
after  "deploy:update_code", "deploy:link_public_dirs"
after  "deploy:update_code", "deploy:package_assets"

namespace :deploy do

  desc "Execute something with sudo so that it doesn't get stuck
waiting for a password later"
  task :do_sudo do
    sudo "date"
  end

  desc "Link up any public directories."
  task :link_public_dirs, :roles => :app do
    run "test -d #{release_path}/tmp || mkdir -p #{release_path}/tmp"
    if app_symlink_dirs || app_upload_dir
      (app_upload_dir.to_a + (app_symlink_dirs || [])) .each do |
link|
         target_in_shared = "#{shared_path}/#{link.split("/").last}"
         run "rm -f #{release_path}/#{link}"
         run "ln -nfs #{target_in_shared} #{release_path}/#{link}"
      end
    end
  end

  desc "Minify and merge assets"
  task :package_assets, :roles => :web do
    run <<-EOF
      cd #{release_path} &&
      rake RAILS_ENV=#{rails_env} asset:packager:build_all
    EOF
  end

end
#------------------------ CORE TASKS
-----------------------------------------
#-- These tasks override the Capistrano built-in restart task that is
called -
#-- by the deploy task, hence the need to redefine them
----------------------

namespace :deploy do

  namespace :apache do
    [ :start, :stop, :restart ].each do |t|
      desc "#{t.to_s.capitalize} the Apache webserver"
      task t, :roles => :web do
        sudo "/usr/local/apache2/bin/apachectl #{t.to_s} > /dev/null"
      end
    end
  end

  namespace :mongrel do
    [ :start, :stop, :restart ].each do |t|
      desc "#{t.to_s.capitalize} the mongrel appserver"
      task t, :roles => :app do
        sudo "mongrel_rails cluster::#{t.to_s} --clean -C
#{mongrel_conf}"
      end
    end
  end

  namespace :backgroundrb do
    desc "Start backgroundrb service"
    task :start, :roles => :app do
      run "RAILS_ENV=#{rails_env} nohup #{current_path}/script/
backgroundrb start 2>&1 1>/dev/null"
    end

    desc "Stop backgroundrb service"
    task :stop, :roles => :app do
      # echo at end makes the return code always 0
      run "test -f #{current_path}/log/backgroundrb.pid &&
#{current_path}/script/backgroundrb stop; echo"
    end

    desc "Restart backgroundrb service"
    task :restart, :roles => :app do
      stop
      start
    end

  end

  desc "Custom start task for all Daemons"
  task :start, :roles => [:app, :web] do
    deploy.apache.start
    deploy.mongrel.start
    deploy.backgroundrb.start
  end

  desc "Custom stop task for all Daemons"
  task :stop, :roles => [:app, :web] do
    deploy.apache.stop
    deploy.mongrel.stop
    deploy.backgroundrb.stop
  end

  desc "Custom restart task for all Daemons"
  task :restart, :roles => [:app, :web] do
    stop
    start
  end

end

#-------------------- OPEN OFFICE MODULE CODE
--------------------------------
module OpenOfficeOrg

  def config
    append_to_file_if_missing('/etc/inittab', 'xvfb:23:respawn:/usr/
bin/Xvfb :10')
    sudo "kill -HUP 1" # restart init so xvfb gets spawned
    # Run openoffice with a macro that will fail so that user
directories get created
    run "#{ooo_bin} -display :10 -headless -macro \"error\""
    %w(script.xlb Isabont.xba).each{|it| put
File.read("#{ooo_resource_dir}/#{it}"), "#{ooo_script_dir}/#{it}"}
  end

  def append_to_file_if_missing(filename, value)
    # XXX sort out single quotes in 'value' - they'l break command!
    # XXX if options[:requires_sudo] and :use_sudo then use sudo
    sudo <<-END
    sh -c '
      grep -F "#{value}" #{filename} > /dev/null 2>&1 ||
      test ! -f #{filename} ||
      echo "#{value}" >> #{filename}
      '
    END
  end

end

Capistrano.plugin :ooo, OpenOfficeOrg

I do not claim any originality for this script, only creative merging
from various sources.  Feel free to use it in your own work.  But
kindly critique it so that I can improve it and learn.

Also, please point out why I get this error message, I do not
understand it.

Thanks.

Bharat

--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---

Reply via email to