Skip to content

Instantly share code, notes, and snippets.

@loganhasson
Created July 22, 2014 18:43
Show Gist options
  • Save loganhasson/1109b20e7ef860d09525 to your computer and use it in GitHub Desktop.
Save loganhasson/1109b20e7ef860d09525 to your computer and use it in GitHub Desktop.
Sample mina deploy
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
set :domain, "ip_address"
set :deploy_to, "/path/to/app"
set :app_path, "#{deploy_to}/#{current_path}"
set :repository, "ssh_clone_url"
set :branch, "branch"
set :user, "username"
task :environment do
end
task :setup => :environment do
queue! %[mkdir -p "#{deploy_to}/shared/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"]
queue! %[mkdir -p "#{deploy_to}/shared/pids"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/pids"]
queue! %[mkdir -p "#{deploy_to}/shared/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
invoke :'git:clone'
invoke :'bundle:install'
to :launch do
invoke :'unicorn:restart'
end
end
end
namespace :unicorn do
desc "Restart unicorn"
task :restart => :environment do
queue "if kill -0 `cat #{deploy_to}/shared/pids/unicorn.pid`> /dev/null 2>&1; then kill -9 `cat #{deploy_to}/shared/pids/unicorn.pid`; else echo 'Unicorn is not running'; fi"
queue "cd #{app_path} && unicorn -c config/unicorn.rb -D -E production"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment