Artix Linux Forum

Init systems => runit => Topic started by: pshaw on 26 July 2022, 18:27:44

Title: runit service "requires"
Post by: pshaw on 26 July 2022, 18:27:44
I am looking at using gunicorn to serve uwsgi unix sock to nginx.

I need nginx service to "require" gunicorn service be running.

Or Generally:  I need Service A to run Service B.  --> B "requires" A

Does this exist in runit?
Title: Re: runit service "requires"
Post by: artoo on 26 July 2022, 19:04:53
Not really, despite being popular, runit is the weakest init we offer in terms of features.
It does not have  builtin dependency handling, which I find annoying.
Title: Re: runit service "requires"
Post by: capezotte on 26 July 2022, 20:20:10
You could add sv start gunicorn || exit 1 as the second line (i.e. after #!/bin/sh and before exec nginx) of nginx's run file, so starting nginx also starts gunicorn. That's the closest thing runit has to dependency handling.

Adding a conf script for nginx-runit would be nice for this use case.
Title: Re: runit service "requires"
Post by: qontinuum on 26 July 2022, 21:21:31
You could add sv start gunicorn || exit 1 as the second line (i.e. after #!/bin/sh and before exec nginx) of nginx's run file, so starting nginx also starts gunicorn. That's the closest thing runit has to dependency handling.

If you don't want your nginx service to fail and restart until gunicorn is ready (I don't know how fast it starts) you should also provide a good check file so that the sv start[\tt] also actually waits for the service to be ready.

Adding a conf script for nginx-runit would be nice for this use case.

Actually we could craft some dependency and configuration management facility in kind of a standard way for all the services, will try to do something.
Title: Re: runit service "requires"
Post by: nous on 27 July 2022, 11:58:30
Actually we could craft some dependency and configuration management facility in kind of a standard way for all the services, will try to do something.
You're spoiling our users...