#require 'capistrano/ext/multistage'
#require 'capistrano-helpers/php'
#require 'capistrano-helpers/shared'
#set :repository, "/home/mlzboy/my/haha"
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano" # Load RVM's capistrano plugin.
set :rvm_ruby_string, 'ruby-1.9.2-p0' # Or whatever env you want it to run in.
set :rvm_type, :user
set :application, "b2c2"
set :ip,"192.168.1.103"
set :repository, "#{ip}:/home/mlzboy/git/b2c2.git"
set :use_sudo, false
default_run_options[:pty] = true
#set :scm, :none
set :scm,:git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
#set :deploy_via, :copy
set :deploy_to, "/home/mlzboy/b2c2"
#set(:path) { Capistrano::CLI.ui.ask("Type a path to deploy: ") }
#set(:repository) { fetch(:path) }
set :user,"mlzboy"
#set :username,"mlzboy"
set :password,"zzzzzz"
role :web, ip # Your HTTP server, Apache/etc
role :app, ip # This may be the same as your `Web` server
role :db, ip, :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
namespace :my_tasks do
desc "Create database.yml and asset packages for staging"
task :symlink, :roles => [:app] do
symlink_hash = {
"#{shared_path}/config/database.yml" => "#{release_path}/config/database.yml",
"#{shared_path}/config/smtp_gmail.yml" => "#{release_path}/config/smtp_gmail.yml",
#"#{shared_path}/system" => "#{release_path}/public/system",
#"#{shared_path}/log" => "#{release_path}/log"
}
symlink_hash.each do |source, target|
run "ln -snf #{source} #{target}"
end
#run "cd #{deploy_to}/current && bundle install vendor/gems"
#run "cd #{deploy_to}/current && #{try_sudo} bundle install"
#run "cd #{deploy_to}/current && rake db:migrate"
end
end
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
bundler.create_symlink
run "cd #{release_path} && bundle install --without test"
end
end
after 'deploy:update_code', 'bundler:bundle_new_release'
after "deploy:update_code", "my_tasks:symlink"
#after :deploy, "deploy:restart"