Last active
October 26, 2024 10:55
-
-
Save arteezy/5d53d99f6ee617fae1f0db0576fdd418 to your computer and use it in GitHub Desktop.
Manage Puma with systemd and rbenv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Puma Rails Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=deploy | |
WorkingDirectory=/home/deploy/app/current | |
ExecStart=/home/deploy/.rbenv/bin/rbenv exec bundle exec puma -C /home/deploy/app/shared/config/puma.rb | |
ExecStop=/home/deploy/.rbenv/bin/rbenv exec bundle exec pumactl -S /home/deploy/app/shared/tmp/pids/puma.state stop | |
TimeoutSec=15 | |
Restart=always | |
[Install] | |
WantedBy=multi-user.target |
actually i just figured it out, it was the ExecStop
declaration that was causing it, once i removed that, i had proper restarts
blah, because i'm using sockets. puma's own documentation is correct https://github.com/puma/puma/blob/master/docs/systemd.md
Thank you! This was a life saver.
Thank you so much for this.
I made some modification to mine.
Puma Service Configuration
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
# Preferably configure a non-privileged user
User=deploy
# The path to the your application code root directory
WorkingDirectory=/home/deploy/my-app
# The command to start Puma
ExecStart=/home/deploy/.rbenv/shims/puma -C /home/deploy/my-app/config/puma.rb
# The command to stop Puma
ExecStop=/home/deploy/.rbenv/shims/puma -S /home/deploy/my-app/config.puma.rb
# Path to PID file so that systemd knows which is the master process
PIDFile=/home/deploy/my-app/tmp/pids/puma.pid
# Should systemd restart puma?
# Use "no" (the default) to ensure no interference when using
# stop/start/restart via `pumactl`. The "on-failure" setting might
# work better for this purpose, but you must test it.
# Use "always" if only `systemctl` is used for start/stop/restart, and
# reconsider if you actually need the forking config.
Restart=always
[Install]
WantedBy=multi-user.target
Hey I did the same but that prompt me to enter password I am not sure what the password is .... Can anyone help me on this ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For whatever reason I had to use
ExecStart=/bin/bash -lc 'bundle exec puma -C {deploy_dir}/shared/config/puma/production.rb'
in mypuma.service
, otherwise i was getting the error below. Interestingly enough, i never noticed until i was tailing the logs because it was just immediately relaunching so i didn't even notice