Created
October 19, 2015 10:48
-
-
Save phamonyut/84a7a74a12820da2c55c to your computer and use it in GitHub Desktop.
example mina deploy.rb
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
# config/deploy.rb | |
require 'mina/bundler' | |
require 'mina/rails' | |
require 'mina/git' | |
require 'mina/rbenv' | |
set :rbenv_path, '/usr/local/rbenv' | |
set :domain, '<your_ip>' | |
set :deploy_to, '<your_deploy_path>' | |
set :repository, '<your_git_repository>' | |
set :branch, 'master' | |
set :user, '<your_username>' | |
set :keep_releases, 4 | |
set :shared_paths, ['config/database.yml', 'log', 'config/application.yml', 'public/system', 'tmp/pids'] | |
task :environment do | |
invoke :'rbenv:load' | |
end | |
task setup: :environment do | |
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/log") | |
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log") | |
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/config") | |
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config") | |
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp") | |
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp") | |
queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/pids") | |
queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/pids") | |
queue! %(touch "#{deploy_to}/#{shared_path}/config/database.yml") | |
queue! %(touch "#{deploy_to}/#{shared_path}/config/application.yml") | |
queue %(echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml'.") | |
queue %(echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/application.yml'.") | |
end | |
desc 'Deploys the current version to the server.' | |
task deploy: :environment do | |
deploy do | |
invoke :'git:clone' | |
invoke :'deploy:link_shared_paths' | |
invoke :'bundle:install' | |
invoke :'rails:db_migrate' | |
invoke :'rails:assets_precompile' | |
invoke :'deploy:cleanup' | |
to :launch do | |
queue 'echo "-----> Stop unicorn"' | |
queue! %( | |
test -s /tmp/unicorn.<your_unicorn_pid>.pid && kill `cat /tmp/unicorn.<your_unicorn_pid>.pid` && echo "Stop Ok" && exit 0 | |
echo >&2 "Not running" | |
) | |
queue 'echo "-----> Start unicorn"' | |
queue! %( | |
cd #{deploy_to}/#{current_path} && unicorn -D -c #{deploy_to}/#{current_path}/config/unicorn.rb --env production | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment