Skip to content

Instantly share code, notes, and snippets.

@Epigene
Last active October 29, 2015 12:08
Show Gist options
  • Save Epigene/85a8a2580f096fc52cd4 to your computer and use it in GitHub Desktop.
Save Epigene/85a8a2580f096fc52cd4 to your computer and use it in GitHub Desktop.
Boot puma on Ubuntu server boot using Upstart and RVM gemset wrapper

1. Make a wrapper for production gemset

rvm gemdir #=> get current gemset
rvm alias create <app_name> <app_gemset>
# rvm alias create test ruby-2.1.2@test

Find the wrapper path

echo $rvm_path/wrappers/<app_name>

Then prepend the path to whatever command you want to run, e.g.

/home/deployer/.rvm/wrappers/test/ruby -v

2. set up an init.d script for Puma

sudo nano /etc/init.d/puma.sh
  #!/bin/bash
  su - "deployer" -c "cd /home/deployer/apps/<app_name>/current && /home/deployer/.rvm/wrappers/<app_name>/bundle exec pumactl start"
sudo chmod +x /etc/init.d/puma.sh
sudo update-rc.d puma.sh defaults
# sudo update-rc.d puma.sh start 30 2 3 4 5 . stop 21 0 1 6 .

Troubleshooting

If wrapper does not seem to work, consult the rvm documentation

If you mess up init.d startup script linking, the links can be reset using

sudo update-rc.d -f <script_file> remove
# sudo update-rc.d -f puma.sh remove

More at update.rb man pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment