[Unit] Description=MyApp After=network.target [Service] Type=simple User=root # App directory WorkingDirectory=/usr/local/src/my_app # Load the rvm environment when `systemctl start` is called ExecStart=/bin/bash -lc '/usr/local/rvm/rubies/ruby-3.0.2/bin/bundle exec rackup -p 6080 -o 0.0.0.0 -s puma -E production' # Restart when the app or service fails Restart=always # Environment variables the service or app must use Environment=RAILS_ENV=production # `Install` is optional for a service, and it's used here because it's required here. [Install] WantedBy=multi-user.target