propagate signal from entrypoint to tgi

Signed-off-by: Raphael Glon <oOraph@users.noreply.github.com>
This commit is contained in:
Raphael Glon 2024-10-10 18:26:20 +02:00
parent 3dbdf63ec5
commit f18a460181
No known key found for this signature in database
GPG Key ID: 4D4CC6881E12A0C3

View File

@ -1,5 +1,28 @@
#!/bin/bash
child_pid=0
cleanup () {
echo tgi interrupted, cleaning
sig=$(($? - 128))
if [ $sig -le 0 ];then
sig=TERM
fi
echo signal $sig received
if [ $child_pid -gt 0 ] && ps -p $child_pid > /dev/null;then
echo kill child $child_pid
kill -$sig $child_pid
wait $child_pid
child_pid=0
fi
}
trap cleanup INT TERM HUP EXIT ERR
ldconfig 2>/dev/null || echo 'unable to refresh ld cache, not a big deal in most cases'
text-generation-launcher $@
text-generation-launcher $@ &
child_pid=$!
wait $child_pid