Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ltenzil/d7a4b36de8995001ba25948a441fabc7 to your computer and use it in GitHub Desktop.

Select an option

Save ltenzil/d7a4b36de8995001ba25948a441fabc7 to your computer and use it in GitHub Desktop.
Understanding service files
refer
=> https://linuxconfig.org/how-to-create-systemd-service-unit-in-linux
=> https://medium.com/@damuz91/setting-up-puma-as-a-service-in-systemd-in-ubuntu-18-9d2c1fe774e4
[with pumactl]
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
Type=simple
User=myuser
WorkingDirectory=/path/to/my/rails-app
Environment=RAILS_ENV=production
ExecStart=/home/ubuntu/.rvm/gems/ruby-2.3.0/bin/puma -C /path/to/my/rails-app/config/puma/production.rb --pidfile /path/to/my/rails-app/puma.pid -e production
ExecStop=/home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle exec pumactl -F config/puma/production.rb stop
ExecReload=/home/ubuntu/.rvm/gems/ruby-2.3.0/bin/bundle exec pumactl -F config/puma/production.rb phased-restart
Restart=always
KillMode=process
[Install]
WantedBy=multi-user.target
###########
sudo systemctl daemon-reload (reload daemon for loading new service file)
sudo systemctl enable puma
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[Install]
WantedBy=multi-user.target#!/bin/sh -
[Unit]
Description=puma
After=network.target
[Service]
Type=simpleservice
User=deploy_user
Group=deploy_user_group
WorkingDirectory=/path/to/your/application
Environment="RAILS_ENV=production"
Environment="PORT=3000"
ExecStart=/gemset_path/bundle exec puma -C /path/to/your/puma_file.rb /path/to/your/config.ru
PIDFile=/path/to/your/pids/puma.pid
TimeoutSec=3000
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment