2

I am running program using runit to run at startup. I want all the output by from the program that is run by runit to be logged to a file.

I have looked at svlogd but I cannot figure out how to get it running.

3

I cannot figure out how to get it running.

In the daemontools family world, log services are just services like any other. So you run svlogd with a run program just like you would run a "main" service with a run program.

The special things about "log" services are merely that:

  • The "log" service directory is located using a symbolic link from (or a straight subdirectory beneath) the "main" service directory.
  • Some, but not all, daemontools family toolsets tightly bind "log" and "main" services and operate upon the twain as a unit. This is to a degree the case with runit.

Otherwise, they are just like everything else.

So make a "log" service to run svlogd just like you would make any other service, put it into the right place relative to your "main" service, and set things off.

Further reading

1
0

The first thing you have to do is to find out where runit files are on your system. Usually it's /etc/runit/. There, you'll find a directory called sv in which one directory per service is created.

Let's say you want to create a new service called food. You would create create a directory called food in /etc/runit/sv/.

# mkdir /etc/runit/sv/food

Create a run script in /etc/runit/sv/food. Let's say that your service's program is an executable at /opt/bin/foo. In that case your run script will be this.

#!/bin/sh
exec /opt/bin/foo 2>&1

For logging, you should create another directory in /etc/runit/sv/food called log. And in it another run script.

#!/bin/sh
exec svlogd -tt <logs-directory>

Make sure the <logs-directory> exits. And don't forget to make both run scripts executables.

# chmod +x /etc/runit/sv/food/run
# chmod +x /etc/runit/sv/food/log/run

Make a symbolic link of your food directory inside /etc/runit/runsvdir/default

# ln -s /etc/runit/sv/food /etc/runit/runsvdir/default/

To manually start/stop your service simply run:

# sv start food
# sv stop food

Take a loot at this quick start guide for more details.

Notice that unlike the guide, I didn't use chpst in my example. In this case the food service will run as root. Use chpst as suggested by the guide if you want your service to run as a specific user.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.