-
-
Save dxtr/f9a0776b2cc7e03d6ddd to your computer and use it in GitHub Desktop.
Hacking an erlang application deployment with Capistrano 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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