Capistrano setting for stagin and productin in deploy.rb
# Required variables
set :application, "app"
task :staging do
set :user, "root"
set :environment, "staging"
set :repository, 'git@github.com:app.git'
set :revision, "origin/#{environment}"
set :domain, "root@server2180.railsvserver.de"
set :deploy_to, "/var/www/#{application}"
end
task :prod do
set :user, "app"
set :environment, "production"
set :repository, 'git@github.com:app.git'
set :revision, "origin/#{environment}"
set :domain, "user@162.13.152.39"
set :deploy_to, "/var/www/#{application}"
end
namespace :vlad do
desc "Symlinks the upload folder"
remote_task :symlink_assets, :roles => :web do
%w(uploads).each do |file|
run "ln -s #{shared_path}/#{file} #{current_path}/public/#{file}"
end
run "ln -s #{current_path}/public/images #{current_path}/public/assets"
end
desc "Install dependencies"
remote_task :bundle, :roles => :app do
run "cd #{current_path} && bundle install"
end
desc "Start unicorn server"
remote_task :start_unicorn, :roles => :app do
run "cd #{current_path} && unicorn_rails -c #{current_path}/config/unicorn.rb -E #{environment} -D"
end
desc "Stop unicorn server"
remote_task :stop_unicorn, :roles => :app do
run "kill -9 `cat #{shared_path}/pids/unicorn.pid`"
end
desc "Update crontab"
remote_task "crontab:update", :roles => :app do
run "cd #{current_path} && whenever ./config/schedule.rb -w"
end
desc "Full deployment cycle: Update, migrate, restart, cleanup"
remote_task :deploy, :roles => :app do
Rake::Task['vlad:update'].invoke
Rake::Task['vlad:bundle'].invoke
Rake::Task['vlad:stop_unicorn'].invoke
Rake::Task['vlad:start_unicorn'].invoke
Rake::Task['vlad:symlink_assets'].invoke
Rake::Task['vlad:crontab:update'].invoke
Rake::Task['vlad:cleanup'].invoke
# Rake::Task['vlad:resque:restart'].invoke
end
desc "Reset redis community feed caching"
remote_task "app:community_feed:reset" => :app do
run "cd #{current_path} && RAILS_ENV=#{environment} rake app:community_feed:reset_cache"
end
desc "Stop Redis"
remote_task "redis:stop" => :app do
run "kill -9 `cat /var/run/redis.pid`"
end
desc "Start Redis"
remote_task "redis:start" => :app do
run "redis-server /etc/redis/redis.conf"
end
desc "ReStart Redis"
remote_task "redis:restart" => :app do
Rake::Task['vlad:redis:stop'].invoke
Rake::Task['vlad:redis:start'].invoke
end
desc "Configtest Nginx"
remote_task "nginx:config" => :app do
run "/etc/init.d/nginx configtest"
end
desc "ReStart Nginx"
remote_task "nginx:restart" => :app do
run "/etc/init.d/nginx restart"
end
desc "Stop MongoDB"
remote_task "mongodb:stop" => :app do
run "kill -9 `cat /var/run/mongod.pid`"
end
desc "Start MongoDB"
remote_task "mongodb:start" => :app do
run "mongod --config /etc/mongodb/mongod.conf"
end
desc "ReStart MongoDB"
remote_task "mongodb:restart" => :app do
Rake::Task['vlad:mongodb:stop'].invoke
Rake::Task['vlad:mongodb:start'].invoke
end
desc "start resque"
remote_task "resque:start" => :app do
run "cd #{current_path} && RAILS_ENV=#{environment} BACKGROUND=yes PIDFILE=#{shared_path}/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> #{shared_path}/log/resque.out"
end
desc "stop resque"
remote_task "resque:stop" => :app do
run "kill -9 `cat #{shared_path}/pids/resque.pid`"
end
desc "ReStart resque"
remote_task "resque:restart" => :app do
Rake::Task['vlad:resque:stop'].invoke
Rake::Task['vlad:resque:start'].invoke
end
end
#RAILS_ENV=production BACKGROUND=yes PIDFILE=tmp/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> ./log/resque.out
# RAILS_ENV=staging BACKGROUND=yes PIDFILE=tmp/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> ./log/resque.out
set :application, "app"
task :staging do
set :user, "root"
set :environment, "staging"
set :repository, 'git@github.com:app.git'
set :revision, "origin/#{environment}"
set :domain, "root@server2180.railsvserver.de"
set :deploy_to, "/var/www/#{application}"
end
task :prod do
set :user, "app"
set :environment, "production"
set :repository, 'git@github.com:app.git'
set :revision, "origin/#{environment}"
set :domain, "user@162.13.152.39"
set :deploy_to, "/var/www/#{application}"
end
namespace :vlad do
desc "Symlinks the upload folder"
remote_task :symlink_assets, :roles => :web do
%w(uploads).each do |file|
run "ln -s #{shared_path}/#{file} #{current_path}/public/#{file}"
end
run "ln -s #{current_path}/public/images #{current_path}/public/assets"
end
desc "Install dependencies"
remote_task :bundle, :roles => :app do
run "cd #{current_path} && bundle install"
end
desc "Start unicorn server"
remote_task :start_unicorn, :roles => :app do
run "cd #{current_path} && unicorn_rails -c #{current_path}/config/unicorn.rb -E #{environment} -D"
end
desc "Stop unicorn server"
remote_task :stop_unicorn, :roles => :app do
run "kill -9 `cat #{shared_path}/pids/unicorn.pid`"
end
desc "Update crontab"
remote_task "crontab:update", :roles => :app do
run "cd #{current_path} && whenever ./config/schedule.rb -w"
end
desc "Full deployment cycle: Update, migrate, restart, cleanup"
remote_task :deploy, :roles => :app do
Rake::Task['vlad:update'].invoke
Rake::Task['vlad:bundle'].invoke
Rake::Task['vlad:stop_unicorn'].invoke
Rake::Task['vlad:start_unicorn'].invoke
Rake::Task['vlad:symlink_assets'].invoke
Rake::Task['vlad:crontab:update'].invoke
Rake::Task['vlad:cleanup'].invoke
# Rake::Task['vlad:resque:restart'].invoke
end
desc "Reset redis community feed caching"
remote_task "app:community_feed:reset" => :app do
run "cd #{current_path} && RAILS_ENV=#{environment} rake app:community_feed:reset_cache"
end
desc "Stop Redis"
remote_task "redis:stop" => :app do
run "kill -9 `cat /var/run/redis.pid`"
end
desc "Start Redis"
remote_task "redis:start" => :app do
run "redis-server /etc/redis/redis.conf"
end
desc "ReStart Redis"
remote_task "redis:restart" => :app do
Rake::Task['vlad:redis:stop'].invoke
Rake::Task['vlad:redis:start'].invoke
end
desc "Configtest Nginx"
remote_task "nginx:config" => :app do
run "/etc/init.d/nginx configtest"
end
desc "ReStart Nginx"
remote_task "nginx:restart" => :app do
run "/etc/init.d/nginx restart"
end
desc "Stop MongoDB"
remote_task "mongodb:stop" => :app do
run "kill -9 `cat /var/run/mongod.pid`"
end
desc "Start MongoDB"
remote_task "mongodb:start" => :app do
run "mongod --config /etc/mongodb/mongod.conf"
end
desc "ReStart MongoDB"
remote_task "mongodb:restart" => :app do
Rake::Task['vlad:mongodb:stop'].invoke
Rake::Task['vlad:mongodb:start'].invoke
end
desc "start resque"
remote_task "resque:start" => :app do
run "cd #{current_path} && RAILS_ENV=#{environment} BACKGROUND=yes PIDFILE=#{shared_path}/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> #{shared_path}/log/resque.out"
end
desc "stop resque"
remote_task "resque:stop" => :app do
run "kill -9 `cat #{shared_path}/pids/resque.pid`"
end
desc "ReStart resque"
remote_task "resque:restart" => :app do
Rake::Task['vlad:resque:stop'].invoke
Rake::Task['vlad:resque:start'].invoke
end
end
#RAILS_ENV=production BACKGROUND=yes PIDFILE=tmp/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> ./log/resque.out
# RAILS_ENV=staging BACKGROUND=yes PIDFILE=tmp/pids/resque.pid QUEUE=* nohup bundle exec rake environment resque:work >> ./log/resque.out
Comments
Post a Comment