]> git.netwichtig.de Git - user/henk/code/s6/service_directory_template.git/commitdiff
initially populated
authorHendrik Jäger <gitcommit@henk.geekmail.org>
Fri, 25 Aug 2023 10:48:48 +0000 (12:48 +0200)
committerHendrik Jäger <gitcommit@henk.geekmail.org>
Fri, 25 Aug 2023 11:06:46 +0000 (13:06 +0200)
down [new file with mode: 0644]
down-signal [new file with mode: 0644]
finish [new file with mode: 0644]
lock-fd [new file with mode: 0644]
log/run [new file with mode: 0644]
max-death-tally [new file with mode: 0644]
notification-fd [new file with mode: 0644]
run [new file with mode: 0644]
timeout-finish [new file with mode: 0644]
timeout-kill [new file with mode: 0644]

diff --git a/down b/down
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/down-signal b/down-signal
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/finish b/finish
new file mode 100644 (file)
index 0000000..6d0016b
--- /dev/null
+++ b/finish
@@ -0,0 +1,7 @@
+#!/usr/bin/execlineb -P
+
+# TODO:
+# a sane example of handling the arguments would be nice
+
+# cleanup some files related to this service
+rm -rf /tmp/${3}
diff --git a/lock-fd b/lock-fd
new file mode 100644 (file)
index 0000000..c29d957
--- /dev/null
+++ b/lock-fd
@@ -0,0 +1,2 @@
+# TODO: are comments allowed here?
+8
diff --git a/log/run b/log/run
new file mode 100644 (file)
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"
diff --git a/max-death-tally b/max-death-tally
new file mode 100644 (file)
index 0000000..162b201
--- /dev/null
@@ -0,0 +1,2 @@
+# TODO: are comments allowed here?
+10
diff --git a/notification-fd b/notification-fd
new file mode 100644 (file)
index 0000000..9d1305b
--- /dev/null
@@ -0,0 +1,2 @@
+# TODO: are comments allowed here?
+7
diff --git a/run b/run
new file mode 100644 (file)
index 0000000..856f09d
--- /dev/null
+++ b/run
@@ -0,0 +1,28 @@
+#!/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
+backtick HOME { homeof ${RUN_USER} }
+importas -n -u HOME HOME
+
+# 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}
+
+# handle SIGTERM
+trap -x {
+       SIGTERM {
+               pipeline { echo "system_powerdown\n" }
+               s6-ipcclient ${HOME}/${INSTANCE_NAME}-monitor.socket
+               s6-ioconnect -67
+       }
+}
+
+# the command to start and supervise
+imaginary_service -l 127.0.0.1 -p 31337 ${HOME}/run/listener_${INSTANCE_NAME}/${INSTANCE_NAME}.conf
diff --git a/timeout-finish b/timeout-finish
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/timeout-kill b/timeout-kill
new file mode 100644 (file)
index 0000000..cd402cb
--- /dev/null
@@ -0,0 +1,2 @@
+# TODO: are comments allowed here?
+10000