title: How to get a Rails App Deployed with Puma and Capistrano to start on reboot
body: <p>I've managed to successfully deploy a Rails 4, Puma, Nginx App using Capistrano. When I deploy <code>cap production deploy</code> everything works great. My problem is if the server reboots for whatever reason or if it crashes, it doesn't restart.</p>
  
  <p>I'm using a Debian 8 on DigitalOcean. It seems Debian 8 uses <code>systemd</code>, so I've followed the instructions from <a href="https://github.com/puma/puma/blob/master/docs/systemd.md" rel="nofollow">Puma</a> but it didn't work. After some research I've found a couple more scripts and the one that seemed most sensible was this:</p>
  
  <pre><code>[Unit]
  Description=Rails-Puma Webserver
  
  [Service]
  Type=simple
  User=myuser
  WorkingDirectory=/home/myuser/apps/myapp
  ExecStart=/home/myuser/.rvm/rubies/ruby-2.2.2/bin/systemd_rails server -e production
  TimeoutSec=15
  Restart=always
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>I've saved the above file in <code>/etc/systemd/system/rails-puma.service</code> then I've enabled it: <code>sudo systemctl enable rails.service</code> and finally started it: <code>sudo systemctl start rails-puma.service</code></p>
  
  <p>Which unfortunately didn't work. This is the result of <code>sudo systemctl status rails-puma.service</code>:</p>
  
  <pre><code>    ● rails-puma.service - Rails-Puma Webserver
     Loaded: loaded (/etc/systemd/system/rails-puma.service; enabled)
     Active: failed (Result: start-limit) since Thu 2016-07-07 12:11:58 EDT; 4s ago
    Process: 4373 ExecStart=/home/myuser/.rvm/rubies/ruby-2.2.2/bin/systemd_rails server -e production (code=exited, status=203/EXEC)
   Main PID: 4373 (code=exited, status=203/EXEC)
  
  Jul 07 12:11:58 mrcProd systemd[1]: rails-puma.service: main process exited, code=exited, status=203/EXEC
  Jul 07 12:11:58 mrcProd systemd[1]: Unit rails-puma.service entered failed state.
  Jul 07 12:11:58 mrcProd systemd[1]: rails-puma.service start request repeated too quickly, refusing to start.
  Jul 07 12:11:58 mrcProd systemd[1]: Failed to start Rails-Puma Webserver.
  Jul 07 12:11:58 mrcProd systemd[1]: Unit rails-puma.service entered failed state.
  </code></pre>
  
  <p>What am I doing wrong here?</p>