Created
March 17, 2015 02:12
-
-
Save easonhan007/d38700e42b920e60f2c9 to your computer and use it in GitHub Desktop.
mina发布到多台机器的脚本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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