rackup icon indicating copy to clipboard operation
rackup copied to clipboard

compatibility with systemd .socket unit

Open hadmut opened this issue 2 years ago • 1 comments

Hi,

this is a feature request.

I need to start ruby REST API-Servers (sinatra) from systemd. This is in general not a problem, when defining it as a .service unit, running permanently, but keeps the daemons permanently running, even if seldomly used.

systemd therefore offers the .socket units (see man systemd.socket), where systemd acts like the good old inetd (for which the same problem exists), i.e. it can open an inet tcp (or in case of systemd, even a unix domain) socket, and once connected, launches the daemon, passing the socket either on stdin/stdout or via the sd_listen_fds(3), which is a pretty good way to have TCP oder unix domain services run on demand.

But I haven't seen options or documentation for rackup to run under systemd with a socket unit. One can pass a unix domain path name to rackup, but not to run under stdin/stdout or sd_listen_fds.

A first thought was to just run

rackup -o /dev/stdin

but this results in `unlink': Permission denied @ apply2files - /dev/stdin (Errno::EACCES) Connection refused - connect(2) for /dev/stdin (Errno::ECONNREFUSED)

Since systemd is a widely accepted service control system, there should be some integration of rackup into systemd with .socket units, and not just .service units having it continously run.

regards

hadmut avatar Dec 24 '23 01:12 hadmut

You can use a Rack server that supports socket activation natively, e.g. unicorn.

leahneukirchen avatar Dec 24 '23 14:12 leahneukirchen

This is out of scope for rackup, sorry.

ioquatix avatar Nov 01 '24 22:11 ioquatix