summaryrefslogtreecommitdiff
path: root/log/run
diff options
context:
space:
mode:
Diffstat (limited to 'log/run')
-rw-r--r--log/run37
1 files changed, 37 insertions, 0 deletions
diff --git a/log/run b/log/run
new file mode 100644
index 0000000..b483dde
--- /dev/null
+++ b/log/run
@@ -0,0 +1,37 @@
+#!/usr/bin/execlineb -P
+
+# TODO:
+# a sane example of handling the arguments would be nice
+
+# populate some variables
+define RUN_USER jdoe
+define INSTANCE_NAME jane
+define MAIL_RCPT john
+backtick HOME { homeof ${RUN_USER} }
+importas -n -u HOME HOME
+
+define LOGDIR ${HOME}/var/log/s6/imaginary_service-${INSTANCE_NAME}
+define MAIL_FIFO ${LOGDIR}/mail_fifo
+
+# redirect STDERR to STDIN so it can be caught by a logging service
+fdmove -c 2 1
+
+# switch to a different user for running this
+s6-setuidgid ${RUN_USER}
+
+# the command to start and supervise
+s6-log
+ # prepend TAI64N timestamp
+ t
+ # prepent ISO 8601 timestamp
+ T
+ # rotate after 1MiB written
+ s1048576
+ # total size of logdir may be 2GiB
+ S2147483648
+ # filter lines with only spaces
+ -"^[[:space:]]+$"
+ # upon rotation, send log to MAIL_RCPT
+ !"background { redirfd -r 0 ${MAIL_FIFO} mail -s \"instance log: ${INSTANCE_NAME}\" -- ${MAIL_RCPT} } tee ${MAIL_FIFO}"
+ # directory to write logfiles to
+ "${LOGDIR}/logs"