Skip to main content
Topic: runit service "requires" (Read 623 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

runit service "requires"

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?

Re: runit service "requires"

Reply #1
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.

Re: runit service "requires"

Reply #2
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.

Re: runit service "requires"

Reply #3
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.