Skip to content

Instantly share code, notes, and snippets.

@easonhan007
Created March 17, 2015 02:12
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 easonhan007/d38700e42b920e60f2c9 to your computer and use it in GitHub Desktop.
Save easonhan007/d38700e42b920e60f2c9 to your computer and use it in GitHub Desktop.
mina发布到多台机器的脚本
def load_config(server)
thirdpillar_config =YAML.load(File.open('config/mina.yml'))
puts "———-> configuring #{server} server"
set :domain, thirdpillar_config[server]['domain'] #retriving the domain value for current server
set :deploy_to, thirdpillar_config[server]['deploy_to'] #retriving the deploy_to value for current server
set :repository, thirdpillar_config[server]['repository']
set :branch, thirdpillar_config[server]['branch']
end
server = ENV['MINA_ENV'] || 'staging'
puts "deploying with ENV: #{server}"
load_config(server)
#######################################
namespace :unicorn do
set :unicorn_pid, "#{app_path}/tmp/pids/unicorn_cywin.pid"
set :start_unicorn, %{
cd #{app_path} && bundle exec unicorn -c config/unicorn/#{server}.rb -E #{rails_env} -D
}
desc "Start unicorn"
task :start => :environment do
queue 'echo "-----> Start Unicorn"'
queue! start_unicorn
end
desc "Stop unicorn"
task :stop do
queue 'echo "-----> Stop Unicorn"'
queue! %{
mkdir -p "#{app_path}/tmp/pids"
test -s "#{unicorn_pid}" && kill -QUIT `cat "#{unicorn_pid}"` && rm -rf "#{unicorn_pid}" && echo "Stop Ok" && exit 0
echo >&2 "Not running"
}
end
desc "Restart unicorn using 'upgrade'"
task :restart => :environment do
invoke 'unicorn:stop'
invoke 'unicorn:start'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment