Skip to content

Instantly share code, notes, and snippets.

@velenux
Created June 3, 2015 22:38
Show Gist options
  • Save velenux/6883dc221a7d2eae7dcb to your computer and use it in GitHub Desktop.
Save velenux/6883dc221a7d2eae7dcb to your computer and use it in GitHub Desktop.
systemd service to start rails/puma
# based on https://gist.github.com/twtw/5494223
# create systemd service file for rails/puma startup
# 0. [if required: rvm use ruby@default]
# 1. rvm wrapper default systemd rails
# 2. put this file in /etc/systemd/system/rails-puma.service
# 3. systemctl enable rails-puma
# 4. systemctl start rails-puma
[Unit]
Description=Rails-Puma Webserver
[Service]
Type=simple
User=app
WorkingDirectory=/home/app/your-app
ExecStart=/home/app/.rvm/bin/systemd_rails server -e production
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
@sekrett
Copy link

sekrett commented Jul 17, 2017

Where I can find the source for systemd_rails script?

@smikkelsen
Copy link

+1, this isn't very helpful without the systemd_rails script

@rkleine
Copy link

rkleine commented Mar 2, 2018

@okliv
Copy link

okliv commented Nov 19, 2020

you need to create wapper script with rvm

$ su user
$ cd /home/user/app_name
$ alias create [app_name] ruby-[version]@[gemset_name]

and then use this path in puma.serviceconfig path like

$ sudo vim /etc/systemd/system/puma.service
...
User=user
...
ExecStart=/home/[user]/.rvm/wrappers/[app_name]/puma -C /home/[user]/[app_name]/config/puma.rb

(check if $ puma can run without errors in foreground from app directory)

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