]> git.netwichtig.de Git - user/henk/code/s6/service_directory_template.git/blob - run
add a timeout value for the finish script
[user/henk/code/s6/service_directory_template.git] / 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 backtick HOME { homeof ${RUN_USER} }
10 importas -n -u HOME HOME
11
12 # redirect STDERR to STDIN so it can be caught by a logging service
13 fdmove -c 2 1
14
15 # switch to a different user for running this
16 s6-setuidgid ${RUN_USER}
17
18 # handle SIGTERM
19 trap -x {
20         SIGTERM {
21                 pipeline { echo "system_powerdown\n" }
22                 s6-ipcclient ${HOME}/${INSTANCE_NAME}-monitor.socket
23                 s6-ioconnect -67
24         }
25 }
26
27 # the command to start and supervise
28 imaginary_service -l 127.0.0.1 -p 31337 ${HOME}/run/listener_${INSTANCE_NAME}/${INSTANCE_NAME}.conf