I have a Ruby on Rails 5.2.3 app that uses ActiveJob to run a background job that sends an email to users upon registration. In development I run bundle exec rake jobs:work
to start the process. I have my app hosted on DigitalOcean using their Marketplace image which includes a systemd service. This is the systemd service file:
/etc/systemd/system/rails.service
[Unit]
Description=appname
Requires=network.target
[Service]
Type=simple
Environment="RAILS_ENV=production"
User=rails
Group=rails
WorkingDirectory=/home/rails/appname/current
ExecStart=/bin/bash -lc 'bundle exec puma'
TimeoutSec=30s
RestartSec=30s
Restart=always
[Install]
WantedBy=multi-user.target
I've read through the answers to this question but I am still not too sure what to do. Should I create multiple services to run the application and the jobs? Or is there a way to get them to run from the same file in parallel (I'm assuming that this type of service needs to be run in parallel)?