Skip to content

Instantly share code, notes, and snippets.

@dxtr
Forked from spalladino/Capfile
Created December 9, 2015 13:11
Show Gist options
  • Save dxtr/f9a0776b2cc7e03d6ddd to your computer and use it in GitHub Desktop.
Save dxtr/f9a0776b2cc7e03d6ddd to your computer and use it in GitHub Desktop.
Hacking an erlang application deployment with Capistrano 3
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
namespace :deploy do
task :build do
on roles(:app) do
within release_path do
execute :make
end
end
end
task :upstart_config do
on roles(:app) do
user = capture :whoami
config = "\
start on starting manas
stop on stopping manas
respawn
chdir #{current_path}
setuid #{user}
env HOME=#{current_path}
exec erl -pa ebin deps/*/ebin -boot start_sasl -s manas_service_app -config manas_service -noshell -noinput >> /var/log/manas/service.log 2>&1
"
sudo %(sh -c "echo \\"#{config.gsub("\n", "\\n")}\\" > /etc/init/service.conf")
end
end
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
sudo "stop service || true"
sudo "start service"
end
end
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
end
end
after :finishing, 'deploy:cleanup'
before :publishing, 'deploy:build'
before :publishing, 'deploy:upstart_config'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment