3

Installed runit in Debian 7.4 in a Vagrant.

My run script is working, but the moment I create a service/pants/log/ directory I start getting the following error: unable to open supervise/ok. My service continues to run but nothing gets logged.

I've tried two different services and both have the same issue.

I've tried various different service/pants/log/run scripts (mostly using svlogd), I've tried changing permissions on everything (a+rwx), the directory to store logs in exists and has the same permissions.

If I run svlogd straight off the commandline it works as expected.

The bash log below shows what happens as I rename /etc/service/pants/_log to /etc/service/pants/log and back again /etc/service/pants/_log.

root@vwb-debian-wheezy:/etc/service# sv s pants/
run: pants/: (pid 29260) 44931s
root@vwb-debian-wheezy:/etc/service# mv pants/{_,}log/
root@vwb-debian-wheezy:/etc/service# sv s pants/
run: pants/: (pid 29260) 44963swarning: pants/: unable to open supervise/ok: file does not exist
; run: log: (pid 29260) 44963s
root@vwb-debian-wheezy:/etc/service# cat pants/log/run
#!/bin/sh

exec svlogd -ttt /var/log/service/pants/

root@vwb-debian-wheezy:/etc/service# ll pants/
total 12
drwxrwxrwx 2 root root 4096 Jul  3 07:00 log
-rwxrwxrwx 1 root root  442 Jul  3 06:58 run
drwxrwxrwx 2 root root 4096 Jul  2 18:59 supervise
root@vwb-debian-wheezy:/etc/service# ll /var/log/service/
total 8
drwxrwxrwx 2 root root 4096 Jul  2 16:55 pants
root@vwb-debian-wheezy:/etc/service# mv pants/{,_}log/
root@vwb-debian-wheezy:/etc/service# sv s pants/
run: pants/: (pid 29260) 45105s

3 Answers 3

7

Create the run files in /etc/sv/pants/ not /etc/service/pants/.

Then a symlink should be created in /etc/service to /etc/sv/pants to activate the service.

ln -s /etc/sv/pants /etc/service/

While creating the files directly in /etc/service works for just the service, it seems to cause problems when using logging as well.

A service can be deactivated by deleting the symlink in /etc/service/.

2
  • Worked like a charm!
    – develCuy
    Apr 3, 2019 at 23:40
  • I had the problem when upgrading sv services of a phusion/baseimage 0.9 to a 0.11 (ubuntu 18.04). This answer solved my : fatal: unable to open supervise/lock: file does not exist problem. Thanks Jul 6, 2019 at 12:20
2

For the Debian installation, there are two directories: /etc/service and /service. For your service to be effectively controlled, they should be more-or-less mirror images of each other. In your example, for service pants, there should be a symlink /etc/service/pants and a symlink /service/pants, each should point to /etc/sv/pants. You can "cheat" and make /service a symlink itself to /etc/service to get the same effect, but I'm not sure as of yet the full impact of that change.

4
  • 1
    On my Debian Wheezy install I have /etc/sv/ not /service/ as mentioned in my answer above. Ignoring that difference the outcome is the same. Aug 1, 2014 at 15:32
  • 1
    So, after several days of fidgeting with it, it looks like a bug (typo?) in /etc/runit/2, where runsvdir is called with /service instead of /etc/service. I just switched it to /etc/service and didn't bother with the /service symlink, and it appears happy. Aug 17, 2014 at 12:52
  • @AveryPayne Thanks for this answer, I was having the same issue and the symlink worked for me. I'm surprised more people aren't running into this issue and voting this question and answer up.
    – Marc
    Sep 1, 2014 at 10:57
  • It's been a little bit since I posted the answer. After awhile, I didn't care about a symlink floating around in / that much so I went ahead and ln -s /etc/service /service, and let the runsvdir in /etc/runit/2 point to it. It's still happy. Only issue I've run into is writing up all of the /etc/sv scripts needed to get things rolling. But, "it's a good kind of hurt" :) since I've learned a bit more about init, services, debian's version of SysV scripts, etc. in the process. Sep 3, 2014 at 0:35
2

If you are running ubuntu 18.04 or higher and getting the following error

unable to open supervise/ok: file does not exist

or if the runsvdir is not showing up in "grep" output then please runit-systemd package by running the following command

sudo apt install runit-systemd

For ubuntu 18.04 all the above specified answers did not worked for me. I have then found this solution from another askubuntu question

I hope this helps

1
  • This is the answer. Just used it on Debian 10. Mar 13, 2021 at 22:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .