Added systemd

This commit is contained in:
James 2023-12-26 23:57:02 -06:00
parent e6e4949049
commit 1f28eaa381
2 changed files with 24 additions and 2 deletions

View file

@ -9,10 +9,10 @@ Will need ruby; install it via package manager or a ruby manager like rbenv/ruby
#### Option 1: System wide packages
With this example, will basically just ignore the project's Gemfile. Debian 12 has a pretty current ruby version, just use it. It will get pulled in as a required package for puma.
With this example, will basically just ignore the project's Gemfile. Debian 12 has a pretty current ruby version so just using it.
```
sudo apt install puma ruby-rack
sudo apt install ruby ruby-rack puma
sudo gem install roda
```
@ -22,6 +22,7 @@ Run the bundle command from the project's root directory
```
sudo apt install ruby ruby-bundler
bundle config set --local path 'vendor/bundle'
bundle install
```
@ -38,3 +39,7 @@ This default to development mode. Run it in production mode with:
```
RACK_ENV=production puma
```
### Run it with systemd in production
Copy the example myapp.service file to `/etc/systemd/system/` and edit accordingly. The example assumes a user named "myapp" with a group name "myapp", the application files are in `/opt/myapp/`, and puma is the system puma.

17
myapp.service Normal file
View file

@ -0,0 +1,17 @@
[Unit]
Description=My roda template
After=network.target
[Service]
User=myapp
Group=myapp
WorkingDirectory=/opt/myapp
Environment=RACK_ENV=production
ExecStart=/usr/bin/puma
TimeoutStopSec=300
KillMode=mixed
Restart=on-failure
[Install]
WantedBy=multi-user.target