Ubuntu Systemd service for Ruby on Rails
This is an example of a systemd service file for starting a Ruby on Rails app automatically.
File location is /etc/systemd/system
[Unit]
Description=ror-app-name
After=network.target
[Service]
Type=simple
User=ruby
WorkingDirectory=/home/ruby/rorappdirectory
Environment="RAILS_ENV=production"
Environment="RAILS_LOG_TO_STDOUT=enabled"
Environment="PORT=3000"
ExecStart=/home/ruby/.rbenv/shims/bundle exec rails s
TimeoutSec=15
Restart=always
[Install]
WantedBy=multi-user.target
Don't forget to run these commands after saving service file.
sudo systemctl daemon-reload
sudo systemctl enable ror-appname.service
New Comment