Skip to content

Commit

Permalink
lifecycle: add trap to service job for clean exit
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzyfresh committed Nov 10, 2020
1 parent 5cc68cf commit 1757eea
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion e2e/lifecycle/inputs/service.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ EOT
template {
data = <<EOT
#!/bin/sh
function cleanup() {
echo stopping
rm ${NOMAD_ALLOC_DIR}/main-running
exit
}
touch ${NOMAD_ALLOC_DIR}/main-ran
touch ${NOMAD_ALLOC_DIR}/main-running
touch ${NOMAD_ALLOC_DIR}/main-started
Expand All @@ -106,7 +113,17 @@ if [ ! -f ${NOMAD_ALLOC_DIR}/sidecar-running ]; then exit 14; fi
sleep 2
if [ ! -f ${NOMAD_ALLOC_DIR}/poststart-started ]; then exit 15; fi
touch ${NOMAD_ALLOC_DIR}/main-checked
sleep 300
echo trap
trap cleanup SIGINT
echo sleep
while true
do
sleep 1
done
EOT

destination = "local/main.sh"
Expand Down

0 comments on commit 1757eea

Please sign in to comment.