I'd like to keep my unit files in source control (e.g. in config
), such that after a capistrano deploy, the unit will be copied to the systemd
dir, and the service (e.g. puma) will be restarted. What would be the best way to achieve this?
I've thought simply adding a post-deploy task such as (untested code)
namespace :deploy do
[...]
before :published, :systemd
desc 'systemd'
task :systemd do
on roles(:web), in: :groups, limit: 3, wait: 10 do
within release_path do
execute "sudo cp config/puma.service /etc/systemd/system/puma.service"
execute "sudo cp config/puma-init /usr/bin/puma-init"
execute "sudo systemctl daemon-reload"
execute "sudo systemctl restart puma"
end
end
end
end