Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@trushkevich
Last active June 9, 2016 15:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save trushkevich/1eff75af00f9aab3548f to your computer and use it in GitHub Desktop.
Save trushkevich/1eff75af00f9aab3548f to your computer and use it in GitHub Desktop.
Capistrano 3 private_pub tasks
set :private_pub_pid, -> { "#{current_path}/tmp/pids/private_pub.pid" }
namespace :private_pub do
desc "Start private_pub server"
task :start do
on roles(:app) do
within release_path do
with rails_env: fetch(:stage) do
execute :bundle, "exec thin -C config/private_pub/thin_#{fetch(:stage)}.yml -d -P #{fetch(:private_pub_pid)} start"
end
end
end
end
desc "Stop private_pub server"
task :stop do
on roles(:app) do
within release_path do
execute "if [ -f #{fetch(:private_pub_pid)} ] && [ -e /proc/$(cat #{fetch(:private_pub_pid)}) ]; then kill -9 `cat #{fetch(:private_pub_pid)}`; fi"
end
end
end
desc "Restart private_pub server"
task :restart do
on roles(:app) do
invoke 'private_pub:stop'
invoke 'private_pub:start'
end
end
end
after 'deploy:restart', 'private_pub:restart'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment