Few weeks ago I was upgrading legacy infrastructure for small sized project and decided to go with
systemd for service management as I had quite good experience with it while tinkering with my toy apps written in Crystal.
If you want to use systemd for rails/ruby project - there is a great news everyone! capistrano-systemd-multiservice will basically do the work for you and it I must say - it works just great.
There are some caveats worth mentioning tho:
WantedBy = multi-user.targetdoesn’t work on ubuntu for user systemd services - you will want to use
WantedBy = default.targetinstead.
You will need to enable linger with
loginctl enable-lingerfor your particular user(s) that are running the app on your production system.
If you encounter quirks regarding unicorn hot reloading try to set
WorkingDirectoryto current directory in your service declaration.
rvm1-capistrano3you can invoke
rvm1:alias:createto generate nice aliases under
~/.rvm/wrappers/<application>- this is very handy in services declaration as you don’t have to reference ruby version directly (less hassle during ruby upgrade - you can simply invoke alias creation on every deploy).
~/.config/systemd/userdirectory exists on first deploy - this actually probably should we incorporated in