summaryrefslogtreecommitdiff
path: root/run
diff options
context:
space:
mode:
authorHendrik Jäger <gitcommit@henk.geekmail.org>2023-08-25 12:48:48 +0200
committerHendrik Jäger <gitcommit@henk.geekmail.org>2023-08-25 13:06:46 +0200
commit1169d626456c276954c96d515a5a0cd686c61338 (patch)
tree74cf56abfdef9653928e0bf4210d95bde468b258 /run
initially populated
Diffstat (limited to 'run')
-rw-r--r--run28
1 files changed, 28 insertions, 0 deletions
diff --git a/run b/run
new file mode 100644
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