Skip to content

Instantly share code, notes, and snippets.

@huanglong-zz
Created December 13, 2013 09:32
Show Gist options
  • Save huanglong-zz/7941943 to your computer and use it in GitHub Desktop.
Save huanglong-zz/7941943 to your computer and use it in GitHub Desktop.
require 'mina/git'
require 'mina/scp'
# require 'mina/rbenv' # for rbenv support. (http://rbenv.org)
# require 'mina/rvm' # for rvm support. (http://rvm.io)
set :term_mode, nil
set :domain, 'xx.xx.xx.xx'
set :deploy_to, '/www/xx.com'
set :backup_to, '/home/xx/dbbackup'
set :repository, 'git@xx.git'
set :branch, 'beta-branch'
# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'log', 'tmp', 'node_modules']
# Optional settings:
set :user, 'xx' # Username in the server to SSH to.
# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
end
# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
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/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/config"]
queue! %[mkdir -p "#{deploy_to}/shared/node_modules"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/node_modules"]
queue! %[mkdir -p "#{deploy_to}/current/log"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/current/log"]
queue! %[mkdir -p "#{deploy_to}/current/config"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/current/config"]
queue! %[mkdir -p "#{deploy_to}/current/node_modules"]
queue! %[chmod g+rx,u+rwx "#{deploy_to}/current/node_modules"]
queue %[touch "#{deploy_to}/shared/config/database.yml"]
end
desc "Deploys the current version to the server."
task :deploy => :environment do
deploy do
# Put things that will set up an empty directory into a fully set-up
# instance of your project.
invoke :'git:clone'
invoke :'deploy:link_shared_paths'
queue! %[npm install bower -g]
queue! %[bower install --allow-root]
queue! %[npm install grunt -g]
queue! %[npm install kirua -g]
queue! %[npm install grunt-cli]
queue! %[npm install]
to :launch do
queue 'NODE_ENV=production kirua restart'
end
end
end
desc "Start the server."
task :start do
queue %[cd #{deploy_to}/current && NODE_ENV=production kirua start]
end
desc "Restart the server."
task :restart do
queue %[cd #{deploy_to}/current && NODE_ENV=production kirua restart]
end
desc "Stop the server."
task :stop do
queue %[cd #{deploy_to}/current && NODE_ENV=production kirua stop]
end
desc "Get the mongodb launches data."
task :backlaunch do
queue %[cd #{backup_to} && mongoexport -d moveha -c launches -f email,userTypes,create_at -o launches.json]
end
#scp_download(xx@xx.xx.xx.xx:/home/xx/dbbackup/launches.json, /Users/black/Projects/beta/dump)
#scp_upload(/Users/black/Projects/beta/dump, xx@xx.xx.xx.xx:/home/xx/dbbackup/launches.json)
# For help in making your deploy script, see the Mina documentation:
#
# - http://nadarei.co/mina
# - http://nadarei.co/mina/tasks
# - http://nadarei.co/mina/settings
# - http://nadarei.co/mina/helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment