move cap tasks into separate files

This commit is contained in:
r888888888
2015-08-19 16:51:15 -07:00
parent e669b66395
commit ba04068bfc
5 changed files with 114 additions and 119 deletions

View File

@@ -0,0 +1,38 @@
namespace :delayed_job do
desc "Start delayed_job process"
task :start do
on roles(:app) do
within current_path do
hostname = capture("hostname").strip
execute :bundle, "exec", "script/delayed_job", "--queues=default,#{hostname}", "-n 2", "start"
end
end
end
desc "Stop delayed_job process"
task :stop do
on roles(:app) do
within current_path do
execute :bundle, "exec", "script/delayed_job", "stop"
end
end
end
desc "Restart delayed_job process"
task :restart do
on roles(:app) do
find_and_execute_task("delayed_job:stop")
find_and_execute_task("delayed_job:start")
end
end
task :kill do
on roles(:app) do
procs = capture("ps -A -o pid,command").split(/\r\n|\r|\n/).grep(/delayed_job/).map(&:to_i)
if procs.any?
execute "for i in #{procs.join(' ')} ; do kill -s TERM $i ; done"
end
end
end
end

View File

@@ -0,0 +1,28 @@
namespace :nginx do
desc "Shut down Nginx"
task :stop do
on roles(:web) do
as :user => "root" do
execute "/etc/init.d/nginx", "stop"
end
end
end
desc "Start Nginx"
task :start do
on roles(:web) do
as :user => "root" do
execute "/etc/init.d/nginx", "start"
end
end
end
desc "Reload Nginx"
task :reload do
on roles(:web) do
as :user => "root" do
execute "/etc/init.d/nginx", "reload"
end
end
end
end

View File

@@ -0,0 +1,25 @@
namespace :symlink do
desc "Link the local config files"
task :local_files do
on roles(:app) do
execute :ln, "-s", "#{deploy_to}/shared/config/danbooru_local_config.rb", "#{release_path}/config/danbooru_local_config.rb"
execute :ln, "-s", "#{deploy_to}/shared/config/database.yml", "#{release_path}/config/database.yml"
execute :ln, "-s", "#{deploy_to}/shared/config/newrelic.yml", "#{release_path}/config/newrelic.yml"
end
end
desc "Link the local directories"
task :directories do
on roles(:app) do
execute :rm, "-f", "#{release_path}/public/data"
execute :ln, "-s", "#{deploy_to}/shared/data", "#{release_path}/public/data"
execute :mkdir, "-p", "#{release_path}/public/cache"
execute :mkdir, "-p", "#{deploy_to}/shared/system/cache"
execute :touch, "#{deploy_to}/shared/system/cache/tags.json"
execute :ln, "-s", "#{deploy_to}/shared/system/cache/tags.json", "#{release_path}/public/cache/tags.json"
execute :touch, "#{deploy_to}/shared/system/cache/tags.json.gz"
execute :ln, "-s", "#{deploy_to}/shared/system/cache/tags.json.gz", "#{release_path}/public/cache/tags.json.gz"
end
end
end

View File

@@ -0,0 +1,21 @@
namespace :web do
desc "Present a maintenance page to visitors."
task :disable do
on roles(:app) do
maintenance_html_path = "#{current_path}/public/maintenance.html.bak"
if test("[ -e #{maintenance_html_path} ]")
execute :mv, maintenance_html_path, "#{current_path}/public/maintenance.html"
end
end
end
desc "Makes the application web-accessible again."
task :enable do
on roles(:app) do
maintenance_html_path = "#{current_path}/public/maintenance.html"
if test("[ -e #{maintenance_html_path} ]")
execute :mv, maintenance_html_path, "#{current_path}/public/maintenance.html.bak"
end
end
end
end