Skip to content

Instantly share code, notes, and snippets.

@lsmolic
Created July 26, 2013 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsmolic/6084955 to your computer and use it in GitHub Desktop.
Save lsmolic/6084955 to your computer and use it in GitHub Desktop.
changes to asset auto_deploy
desc <<-DESC
Deploy the system directory to production
DESC
task :fs, :roles => :web, :once => true do
servers = find_servers_for_task(current_task)
puts "SERVERSSSSSSS......>>>>>>>> #{servers}"
servers.each do |server|
port = 22
Array(fetch(:sync_directories, [])).each do |syncdir|
destination, base = Pathname.new(syncdir).split
if File.directory? "#{syncdir}"
# Make a backup
logger.info "backup #{syncdir}"
run "tar cjf #{shared_path}/sync/#{base}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.tar.bz2 #{current_path}/#{syncdir}"
purge_old_backups "#{base}"
else
logger.info "Create '#{syncdir}' directory"
run "mkdir #{current_path}/#{syncdir}"
end
# Sync directory up
logger.info "sync #{syncdir} to #{server}:#{port} from local"
system "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir}/* #{user}@#{server}:#{current_path}/#{syncdir}/"
end
logger.important "sync file system from local to the stage '#{stage}' finished"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment