I'm pretty new to runit. I installed it on a Ubuntu host.
What I did:
1) created a dir testrun
in /etc/sv
2) created a script run
in /etc/sv/testrun/run
, the script content:
#! /bin/bash
exec /root/FP/annotate-output python /root/FP/test.py | logger -t svtest
3) If I call directly /etc/sv/testrun/run it executes successfully
4) I run sv start testrun
(or sv run testrun
, sv restart testrun
), all of them end up with the same error msg:
fail: sv: unable to change to service directory: file does not exist
Any ideas what am I doing wrong? I'm new to runit and base all my actions on the information found here: http://smarden.org/runit/
Your service isn't set up correctly. The reason it worked is that you invoked it directly from the service definition and not from the actual service control.
When runit's service management starts, it expects a
/service
directory to exist, although some installs (like Debian Jessie) currently have it at/etc/service
for reasons unknown. The error message comes from this missing directory, which it is trying to change to, hence theunable to change service directory
message. Do the following as root:This will:
/service
as its working directorytestrun
service, assuming you have it defined at/etc/sv/testrun
runsvdir
will then be able to change its directory into/service
, find your symlink fortestrun
, and then launch it. You can verify this by usingps fax
orpstree -A
to see the process tree; there should be arunsv
with your command attached to it. Note: sometimes it may take a second or two for the runsvdir process to get its head oriented, so if you look right away and don't see it in the process tree, wait 2-3 seconds and try again, and it should show up. This appears to only happen when it starts up.It seems that
sv
controls services that are started and monitored byrunit
(usingrunsv
). As runit on my machine does not actually replacesysvinit
, it does not run and does not monitor the/services/
which should contain symbolic links to/etc/sv/
directories.Running
runsv /etc/sv/testrun/
seems to do the expected runit behavior.