2

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
Rudolf Vavruch
  • 1,215
  • 2
  • 11
  • 16

3 Answers3

5

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/.

Rudolf Vavruch
  • 1,215
  • 2
  • 11
  • 16
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.

Avery Payne
  • 14,326
  • 1
  • 48
  • 87
  • 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. – Rudolf Vavruch Aug 01 '14 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. – Avery Payne Aug 17 '14 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 01 '14 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. – Avery Payne Sep 03 '14 at 00: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

Kumaran
  • 151
  • 2