commit: 066e5e3ed7312fd7aff3603b72122647e7f3630c Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> AuthorDate: Wed Mar 13 05:14:54 2024 +0000 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> CommitDate: Wed Mar 13 05:16:01 2024 +0000 URL: https://gitweb.gentoo.org/proj/fifo-cronolog.git/commit/?id=066e5e3e
fix: standardize init setup Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> README.md | 21 +++++++++++++++++++-- fifo-cronolog.c | 2 +- openrc/fifo-cronolog.confd | 7 ++++--- systemd/README.md | 4 ---- systemd/[email protected] | 4 +++- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7ec95e7..7e910fe 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,28 @@ -fifo-cronolog -------------- +# fifo-cronolog This is a little tool that connects a named pipe/FIFO into the stdin of `cronolog`. This is useful for cases where the logging destination cannot be specified as a program. It was originally written to do logging from Squid, but later re-used for Nginx & other tools. +## openrc +1. `cp /etc/conf.d/fifo-cronolog /etc/conf.d/fifo-cronolog.$INSTANCE` +2. Edit `/etc/conf.d/fifo-cronolog.$INSTANCE` +3. `ln -s /etc/init.d/fifo-cronolog /etc/init.d/fifo-cronolog.$INSTANCE` +4. `rc-update add fifo-cronolog.$INSTANCE default` + +## systemd +1. Put env into a supported directory, using the entire name of the unit, with instance suffix. + e.g. `/etc/default/fifo-cronolog@example` +2. `systemctl enable fifo-cronolog@example` +3. Use systemd overrides if you need to add dependencies. + +### systemd environment load order +- `/etc/sysconfig/` +- `/etc/default/` +- `/run/sysconfig/` + +## how it works Cronolog's canonical example, in an Apache configuration ``` TransferLog "|/www/sbin/cronolog /www/logs/%Y/%m/%d/access.log" diff --git a/fifo-cronolog.c b/fifo-cronolog.c index c2875d6..f30bda4 100644 --- a/fifo-cronolog.c +++ b/fifo-cronolog.c @@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause #include <errno.h> #include <string.h> -#define VERSION "1.2.1" +#define VERSION "1.2.2" char *pidfile; diff --git a/openrc/fifo-cronolog.confd b/openrc/fifo-cronolog.confd index a73e291..1349d3e 100644 --- a/openrc/fifo-cronolog.confd +++ b/openrc/fifo-cronolog.confd @@ -1,10 +1,11 @@ # Various paths: -PIDFILE="/var/run/fifo-cronolog.pid" -FIFO="/var/lib/fifo-cronolog.fifo" +INSTANCENAME="example" +PIDFILE="/var/run/fifo-cronolog.$INSTANCENAME.pid" +FIFO="/var/lib/fifo-cronolog.$INSTANCENAME.fifo" # User/Group of the fifo owner, will be set during startup if the fifo doesn't exist already FIFO_OWNER="root:root" FIFO_PERMS="0600" -LOGS="/var/log/fifo-cronolog/transfer/%Y%m%d.log" +LOGS="/var/log/example/%Y%m%d.log" # Uncomment and add the service name you want to use it for to ensure # fifo-cronolog start first. diff --git a/systemd/README.md b/systemd/README.md deleted file mode 100644 index 1d88021..0000000 --- a/systemd/README.md +++ /dev/null @@ -1,4 +0,0 @@ -1. Put env into `/etc/systemd-env/`, using the entire name of the unit, with instance suffix, and an extra `.env`, - e.g. `/etc/systemd-env/[email protected]` -2. `systemctl enable fifo-cronolog@example` -3. Use systemd overrides if you need to add dependencies. diff --git a/systemd/[email protected] b/systemd/[email protected] index 0ab0962..a6a6133 100644 --- a/systemd/[email protected] +++ b/systemd/[email protected] @@ -2,7 +2,9 @@ Description=fifo-cronolog.%i [Service] Type=forking -EnvironmentFile=/etc/systemd-env/%n.env +EnvironmentFile=-/etc/sysconfig/%N +EnvironmentFile=-/etc/default/%N +EnvironmentFile=-/run/sysconfig/%N PIDFile=/run/%N.pid ExecStartPre=/usr/sbin/fifo-cronolog-setup $FIFO $FIFO_OWNER $FIFO_PERMS ExecStart=/usr/sbin/fifo-cronolog /run/%N.pid $FIFO $LOGS
