title: Capistrano and systemd integration
body: <p>I'd like to keep my unit files in source control (e.g. in <code>config</code>), such that after a capistrano deploy, the unit will be copied to the <code>systemd</code> dir, and the service (e.g. puma) will be restarted. What would be the best way to achieve this?</p>
  
  <p>I've thought simply adding <a href="https://stackoverflow.com/a/30191727/165753">a post-deploy task</a> such as (untested code)</p>
  
  <pre><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
  </code></pre>