diff --git a/lib/tasks/copy_site.rake b/lib/tasks/copy_site.rake index 69faec9..1d5b636 100644 --- a/lib/tasks/copy_site.rake +++ b/lib/tasks/copy_site.rake @@ -51,14 +51,14 @@ namespace :create_site do ls_out = exec_ssh_command_for_copy(ssh, "ls #{@site_construct.full_site_path}/app").join("\n") if ls_out.include?("No such") || org_creating if @site_construct.server_type == template_site.server_type - exec_ssh_command_for_copy(ssh,"rsync -arv --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) + exec_ssh_command_for_copy(ssh,"rsync -arv --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) else exec_ssh_command_for_copy(ssh,"sudo -p 'sudo password:' apt-get install -y sshpass") - outputs = exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) + outputs = exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) if outputs.join("\n").include?("Host key verification failed") exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keygen -f \"$HOME/.ssh/known_hosts\" -R #{server.ip}") exec_ssh_command_by_sudo_for_copy(ssh,"ssh-keyscan -H #{server.ip} >> ~/.ssh/known_hosts") - exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) + exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete --exclude={tmp/cache/,tmp/unicorn.sock,tmp/pids/*#{extra_exclude_path}} #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/ #{args.path}/#{@site_construct.get_site_name}/",true) end end end @@ -77,7 +77,7 @@ namespace :create_site do exec_ssh_command_by_sudo_for_copy(ssh,"rm -rf #{args.path}/#{@site_construct.get_site_name}/dump_xxxx") else exec_ssh_command_by_sudo_for_copy(ssh,"sshpass -p '#{server.password}' ssh #{server.account}@#{server.ip} 'mongodump -d #{template_site.db_name} -o #{template_site.path}/#{template_site.site_name}/dump_xxxx'") - exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --delete #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/dump_xxxx/ #{args.path}/#{args.site_name}/dump_xxxx/") + exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{template_site.path}/#{template_site.get_site_name}/dump_xxxx/ #{args.path}/#{args.site_name}/dump_xxxx/") exec_ssh_command_by_sudo_for_copy(ssh,"mongorestore --drop -d #{args.db_name} #{args.path}/#{@site_construct.get_site_name}/dump_xxxx/#{template_site.db_name}") exec_ssh_command_by_sudo_for_copy(ssh,"rm -rf #{args.path}/#{@site_construct.get_site_name}/dump_xxxx") exec_ssh_command_by_sudo_for_copy(ssh,"sshpass -p '#{server.password}' ssh #{server.account}@#{server.ip} 'rm -rf #{template_site.path}/#{template_site.get_site_name}/dump_xxxx'") @@ -97,10 +97,10 @@ namespace :create_site do absolute_path = (path[0] == "/") ? path : ("#{template_site.path}/#{template_site.get_site_name}/#{path}") absolute_path = (absolute_path[-1] == "/") ? absolute_path : (absolute_path + "/") if @site_construct.server_type == template_site.server_type - exec_ssh_command_for_copy(ssh,"rsync -arv --delete #{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/") + exec_ssh_command_for_copy(ssh,"rsync -arv --info=progress2 --no-inc-recursive --delete #{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/") else server = SiteServer.where(:server_name => template_site.server_type).first - exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --delete #{server.account}@#{server.ip}:#{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/") + exec_ssh_command_for_copy(ssh,"sshpass -p \"#{server.password}\" rsync -arv --info=progress2 --no-inc-recursive --delete #{server.account}@#{server.ip}:#{absolute_path} #{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/") end outputs = outputs.gsub(path,"#{args.path}/#{args.site_name}/#{Pathname.new(absolute_path).basename}/") end @@ -112,8 +112,8 @@ namespace :create_site do update_infos("Finish checking extensions!") update_infos("execing bundle install...") - exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nbundle install'",true) - exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nbundle install'") + exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nrm -f Gemfile.lock\nbundle install'",true) + exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nrm -f Gemfile.lock\nbundle install'") update_infos("finish execing bundle install") update_infos("starting #{args.site_name} web server to development") outputs = exec_ssh_command_by_sudo_for_copy(ssh,"bash -l -c 'cd #{args.path}/#{@site_construct.get_site_name}\nkill -s TERM `fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" kill -s TERM `sudo -p \"sudo password:\" fuser tmp/unicorn.sock`\nsudo -p \"sudo password:\" rm -f tmp/pids/unicorn.pid\nbundle exec unicorn_rails -c config/unicorn.rb -D -E development\n'")