Run Ruby Rails Server As Daemon? I found literally 10s of examples, but none seem to work. I find it odd that Ruby on Rails is so popular and something so basic is so apparently confusing? Anyone have an example of Ruby on Rails on Raspberry Pi, I.e. Debian 9, where Puma based Ruby Rails application is run as a daemon, i.e. system?

Thank you for your post, the structure and configuration of the systemd files, for the service, I have figured out, what is missing is that actual ExecuteStart command that works. There are many examples but none seem to work correctly with the specific Ruby/Rails configuration that is current in Debian 9 on Pi.

Thanks for the reply. The service versus socket scenario was something I found in one of the various examples, that looking interesting, but it complicated the issue. What I wanted to do was to have each rails application use a different port, this is all development level work, but would let me isolate traffic per port with ease, for analysis.

You are correct, the working directory should be qualified, and I agree adding Standard*/Syslog is a good idea. Last night, after some serious isolation differences and comparison of examples, I got a simple variant working. The sample below works, and it is the minimum, I still need to incorporate some of the suggestions you noted, I will do that and post and update version soon. But for those that may find this interesting, here is what is working for now now.

I change the default port in the config/puma.rb script, per application, so demo is 3000, hello is 3001, etc. for example. Long term, I will set the rails applications to a production comparable environment, where I plan to use environment variables to control the port assignment, but I am still learning rails, so this is sufficient for now.

What is interesting is that their are so many variants to invoking the rails server to execute the application, the examples vary even within the same OS, distribution, etc. This has always been what I consider good and bad about Linux, to many ways to do the same thing. Having also been a engineer/designer/programmer on Macintosh and Windows, where the variance is less, ah, diverse? But I digress.

I will post a more detailed unit file with the suggestions you noted soon as I noted above.

Despite the fact that a lot of people complain about systemd I have found it makes setting up such servers very easy. It has been reliable for us on many cloud servers for a long time now.

I have also have multiple HTTP servers running on one machine, listening on different ports. I use node.js because it's, well, more cool. All those services are accessed through nginx on the regular port 80 or more usually 443. It's very easy to configure nginx to proxy pass different URLs to the different services on other ports.

Yes, there are many ways to skin cats with Linux. Can be annoying because it means you end up reading lot of advice on the net that is out of date or does not apply to your Linux distro or is not suitable for you use case or mostly just wrong!