Skip to content

Instantly share code, notes, and snippets.

@SergXIIIth
Created August 25, 2011 08:43
Show Gist options
  • Save SergXIIIth/1170251 to your computer and use it in GitHub Desktop.
Save SergXIIIth/1170251 to your computer and use it in GitHub Desktop.
rake
def iis
path = File.absolute_path "website"
path = path.gsub('/', '\\')
sh "\"c:/Program Files (x86)/IIS Express/iisexpress\" /path:#{path} /port:9090"
end
def build
cd ".."
sln = FileList["*.sln"][0]
sh "c:/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe #{sln}"
end
# -*- encoding : utf-8 -*-
namespace :db do
require "date"
production_server = "server:port"
task :backup do
dest_db = "dest_#{DateTime.now.strftime('%Y_%m_%d_%H_%M_%S')}"
pull = "
db = connect('#{dest_db}');
printjson(db.copyDatabase('source_db', '#{dest_db}', '#{production_server}', 'login', 'password'));
"
sh "mongo --eval \"#{pull}\""
end
task :dev do
source_db = ENV['source']
if source_db.nil?
raise "source should be nil"
end
pull = "
db_dev = connect('db_dev');
printjson(db_dev.dropDatabase());
printjson(db_dev.copyDatabase('#{source_db}', 'db_dev'));
"
sh "mongo --eval \"#{pull}\""
end
task :restory do
rm_rf "dump"
sh "mongodump --db db_dev"
sh "mongorestore --host dest_server --port 10014 --db dest_db --username login --password pas dump/db_dev --drop --verbose"
end
task :run do
sh "sudo rm /var/lib/mongodb/mongod.lock"
sh "sudo start mongodb"
end
end
def kill_web
thin = '"ruby /home/msa/.rvm/gems/ruby-1.9.2-p180@rails31/bin/thin start"'
pidList = `ps -C #{thin} -o pid`.split.map! {|s| s.to_i}
pidList.shift # discard header
pidList.reject! {|pid| pid == $$}
pidList.each do |pid|
puts "kill -9 #{pid}"
`kill -9 #{pid}`
end
end
task :kill do
kill_web
end
task :web do
kill_web
#sh "sudo rvm gemset use rails31"
sh "thin start"
end
def push
sh "hg incoming" do |ok, res|
if ok
sh "hg pull"
sh "hg merge" do |ok, res|
if ok
sh "hg com -A -m\"Merge\""
else
sh "hg up"
end
end
end
end
sh "hg push"
end
task :live do
sh 'git add .' do end
sh 'git commit -a -m "deploy"' do end
sh 'git push heroku master'
end
task :up do
sh "hg pull"
sh "hg up"
end
task :done do
raise "Paramert 'm' is require" if ENV['m'].nil?
sh "hg com -A -m\"#{ENV['m']}\"" do |ok, res|
end
push()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment