]> git.netwichtig.de Git - user/henk/code/s6/service_directory_template.git/blob - log/run
b483dde3b7748bd2a2a0cb5dd19c421321657252
[user/henk/code/s6/service_directory_template.git] / log / run
1 #!/usr/bin/execlineb -P
2
3 # TODO:
4 # a sane example of handling the arguments would be nice
5
6 # populate some variables
7 define RUN_USER jdoe
8 define INSTANCE_NAME jane
9 define MAIL_RCPT john
10 backtick HOME { homeof ${RUN_USER} }
11 importas -n -u HOME HOME
12
13 define LOGDIR ${HOME}/var/log/s6/imaginary_service-${INSTANCE_NAME}
14 define MAIL_FIFO ${LOGDIR}/mail_fifo
15
16 # redirect STDERR to STDIN so it can be caught by a logging service
17 fdmove -c 2 1
18
19 # switch to a different user for running this
20 s6-setuidgid ${RUN_USER}
21
22 # the command to start and supervise
23 s6-log
24         # prepend TAI64N timestamp
25         t
26         # prepent ISO 8601 timestamp
27         T
28         # rotate after 1MiB written
29         s1048576
30         # total size of logdir may be 2GiB
31         S2147483648
32         # filter lines with only spaces
33         -"^[[:space:]]+$"
34         # upon rotation, send log to MAIL_RCPT
35         !"background { redirfd -r 0 ${MAIL_FIFO} mail -s \"instance log: ${INSTANCE_NAME}\" -- ${MAIL_RCPT} } tee ${MAIL_FIFO}"
36         # directory to write logfiles to
37         "${LOGDIR}/logs"