Last active
November 16, 2023 16:14
-
-
Save DSKonstantin/708f346f1cf62fb6d61bf6592e480781 to your computer and use it in GitHub Desktop.
Auto start puma via systemctl
This file contains hidden or 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
Article: https://github.com/puma/puma/blob/master/docs/systemd.md | |
#1 nano /etc/systemd/system/puma.service | |
#2 paste from puma.service | |
Commands: | |
# After installing or making changes to puma.service | |
systemctl daemon-reload | |
# Enable so it starts on boot | |
systemctl enable puma.service | |
# Initial start up. | |
systemctl start puma.service | |
# Check status | |
systemctl status puma.service | |
# A normal restart. Warning: listeners sockets will be closed | |
# while a new puma process initializes. | |
systemctl restart puma.service |
This file contains hidden or 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 HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=root | |
Group=root | |
WorkingDirectory=<path_to_project>/current | |
Environment=SECRET_KEY_BASE='<SECRET KEY>' | |
ExecStart=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec puma -C <path_to_project>/shared/puma.rb --daemon | |
ExecStop=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec pumactl -S <path_to_project>/shared/tmp/pids/puma.state -F <path_to_project>/shared/puma.rb stop | |
#Restart=always | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or 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 HTTP Server | |
After=network.target | |
[Service] | |
Type=simple | |
User=root | |
Group=root | |
WorkingDirectory=<path_to_project>/current | |
Environment=RAILS_ENV=production | |
EnvironmentFile=<path_to_project>/current/config/application.yml | |
PIDFile=<path_to_project>/shared/tmp/pids/puma.pid | |
ExecStart=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec puma -C <path_to_project>/shared/puma.rb --daemon | |
ExecStop=/usr/local/rvm/bin/rvm <ruby_version>@<gemset_name> do bundle exec pumactl -S <path_to_project>/shared/tmp/pids/puma.state -F <path_to_project>/shared/puma.rb stop | |
TimeoutSec=15 | |
KillMode=process | |
#Restart=always | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment