Skip to content

Instantly share code, notes, and snippets.

@yosiyuki
Last active March 21, 2024 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yosiyuki/d84ef5f76f9a56ba2e3d9f48c076000d to your computer and use it in GitHub Desktop.
Save yosiyuki/d84ef5f76f9a56ba2e3d9f48c076000d to your computer and use it in GitHub Desktop.
Serverside setup to capistrano restart puma

On server

> loginctl enable-linger [username]
> sudo loginctl enable-linger [username]
> vi .config/systemd/user/xxx_puma_production.service
> systemctl --user enable xxx_puma_production.service
> systemctl --user daemon-reload

File

~/.config/systemd/user/xxx_puma_production.service

[Unit]
Description=Puma HTTP Server for xxx (production)
After=network.target

[Service]
Type=notify
WatchdogSec=10

WorkingDirectory=/var/work/xxx/current
Environment=RAILS_ENV=production
Environment=RBENV_ROOT=/home/xxx/.rbenv
Environment=RBENV_VERSION=3.2.2
ExecStart=/bin/bash -lc 'cd /var/work/xxx/current && /usr/bin/env /home/xxx/.rbenv/shims/bundle exec puma -C /var/work/xxx/current/config/puma/production.rb'
ExecReload=/bin/kill -TSTP $MAINPID

Restart=always
# RestartSec=1

SyslogIdentifier=puma

[Install]
WantedBy=default.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment