blob: fe1382d48d1f8395a6ca57832a8107814294b504 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/bin/execlineb -S1
# the -S1 tells execline to substitute 1 positional parameter
# which for this file is: the name of the service directory
# 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
# notify readiness
-d3
# 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"
|