Skip to content

Instantly share code, notes, and snippets.

@pondpaun7z
Created November 25, 2018 17:43
Show Gist options
  • Save pondpaun7z/88cd9c480b01cbe0f2723635182201b5 to your computer and use it in GitHub Desktop.
Save pondpaun7z/88cd9c480b01cbe0f2723635182201b5 to your computer and use it in GitHub Desktop.
Puma auto start with capistrano structure
# /etc/systemd/system/puma.service
# systemctl daemon-reload
# sudo systemctl [start|stop|enable|restart] puma.service
[Unit]
Description=Puma HTTP Server
After=network.target
# Uncomment for socket activation (see below)
# Requires=puma.socket
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
# Preferably configure a non-privileged user
User=<USER>
# The path to the puma application webbased-vm
# Also replace the "<WD>" place holders below with this path.
WorkingDirectory=<WD>/current
# Helpful for debugging socket activation, etc.
Environment=RBENV_ROOT=/home/<USER>/.rbenv
# The command to start Puma. This variant uses a binstub generated via
# `bundle binstubs puma --path ./sbin` in the WorkingDirectory
# (replace "<WD>" below)
ExecStart=/home/<USER>/.rbenv/bin/rbenv exec bundle exec puma -C <WD>/shared/config/puma.rb
ExecStop=/home/<USER>/.rbenv/bin/rbenv exec bundle exec pumactl -S <WD>/shared/tmp/pids/puma.state -F <WD>/shared/puma.rb stop
RestartSec=10
# Variant: Use config file with `bind` directives instead:
# ExecStart=<WD>/sbin/puma -C config.rb
# Variant: Use `bundle exec --keep-file-descriptors puma` instead of binstub
Restart=always
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment