diff --git a/contrib/runit-init/README.md b/contrib/runit-init/README.md new file mode 100644 index 000000000..fdfa8579e --- /dev/null +++ b/contrib/runit-init/README.md @@ -0,0 +1,71 @@ +Startup services for runit. + +# Configure Per-User Services and Logging + +Create the service dirs: +```bash + $ mkdir ~/.local/service/ + $ mkdir ~/.local/sv/ +``` +`~/.local/sv/` will contain our services which we symlink into `~/.local/sv/` to activate. + +In your `~/.bashrc` or `~/.zshrc`, add this line: +```bash + $ export SVDIR=~/.local/sv/ +``` + +Then as root, make sure you add this to `/root/.(bash|zsh)rc`: +```bash + unset SVDIR +``` + +Now follow these guides: + +* [Per-User Services](https://docs.voidlinux.org/config/services/user-services.html) +* [Logging](https://docs.voidlinux.org/config/services/logging.html) + +To view the logs, open another terminal, switch to root and run the command below. +Leave this window open so we can view the daemon logs. +```bash + # svlogtail daemon +``` + +Finally make sure your user level service is running: +```bash + # sv status runsvdir-narodnik + run: runsvdir-narodnik: (pid 25140) 483s +``` + +# Copy Services + +Copy the directories here over to `~/.local/sv/`: +```bash + $ cp -r darkirc/ ircd/ taud/ ~/.local/sv/ +``` + +Activate them by symlinking them into `~/.local/service/`. We need the full path. +```bash + $ cd ~/.local/service/ + $ ln -s /home/USER/.local/sv/darkirc/ . + $ ln -s /home/USER/.local/sv/ircd/ . + $ ln -s /home/USER/.local/sv/taud/ . +``` + +Now check they are working fine: +```bash + $ sv status darkirc +``` + +You should also view the log output in the window we opened earlier. + +# Short Explanation + +Each directory contains an executable `run` script which launches the daemon. +We must redirect STDERR to STDOUT to get error messages in the log output. + +To enable the log output, we must provide the `log/run` script which contains +the logger command. You can test logger output like this: +```bash + $ vlogger -t darky -p daemon hello123 +``` + diff --git a/contrib/runit-init/darkirc/log/run b/contrib/runit-init/darkirc/log/run new file mode 100755 index 000000000..0c835e20f --- /dev/null +++ b/contrib/runit-init/darkirc/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t darkirc -p daemon diff --git a/contrib/runit-init/darkirc/run b/contrib/runit-init/darkirc/run new file mode 100755 index 000000000..deef3f44b --- /dev/null +++ b/contrib/runit-init/darkirc/run @@ -0,0 +1,4 @@ +#!/bin/sh +DARKFI_DIR="/home/narodnik/src/darkfi/" +exec $DARKFI_DIR/darkirc 2>&1 + diff --git a/contrib/runit-init/ircd/log/run b/contrib/runit-init/ircd/log/run new file mode 100755 index 000000000..009be2818 --- /dev/null +++ b/contrib/runit-init/ircd/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t ircd -p daemon diff --git a/contrib/runit-init/ircd/run b/contrib/runit-init/ircd/run new file mode 100755 index 000000000..4a74ec1c0 --- /dev/null +++ b/contrib/runit-init/ircd/run @@ -0,0 +1,4 @@ +#!/bin/sh +DARKFI_DIR="/home/narodnik/src/darkfi/" +exec $DARKFI_DIR/ircd 2>&1 + diff --git a/contrib/runit-init/taud/log/run b/contrib/runit-init/taud/log/run new file mode 100755 index 000000000..2c5fee195 --- /dev/null +++ b/contrib/runit-init/taud/log/run @@ -0,0 +1,2 @@ +#!/bin/sh +exec vlogger -t taud -p daemon diff --git a/contrib/runit-init/taud/run b/contrib/runit-init/taud/run new file mode 100755 index 000000000..25cb403a6 --- /dev/null +++ b/contrib/runit-init/taud/run @@ -0,0 +1,4 @@ +#!/bin/sh +DARKFI_DIR="/home/narodnik/src/darkfi/" +exec $DARKFI_DIR/taud 2>&1 +