mirror of
https://github.com/serge-chat/serge.git
synced 2024-01-15 09:32:12 +03:00
Enhance Signal Handling for Graceful Termination (#727)
* Enhance Signal Handling for Graceful Termination * Fixed formatting --------- Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
|
||||
set -x
|
||||
|
||||
# Handle termination signals
|
||||
_term() {
|
||||
echo "Received termination signal!"
|
||||
kill -TERM "$redis_process" 2>/dev/null
|
||||
kill -TERM "$serge_process" 2>/dev/null
|
||||
}
|
||||
|
||||
# Install python bindings
|
||||
pip install llama-cpp-python==0.1.78 || {
|
||||
echo 'Failed to install llama-cpp-python'
|
||||
@@ -10,10 +17,16 @@ pip install llama-cpp-python==0.1.78 || {
|
||||
|
||||
# Start Redis instance
|
||||
redis-server /etc/redis/redis.conf &
|
||||
redis_process=$!
|
||||
|
||||
# Start the API
|
||||
cd /usr/src/app/api || exit 1
|
||||
uvicorn src.serge.main:app --host 0.0.0.0 --port 8008 || {
|
||||
echo 'Failed to start main app'
|
||||
exit 1
|
||||
}
|
||||
} &
|
||||
serge_process=$!
|
||||
|
||||
# Set up a signal trap and wait for processes to finish
|
||||
trap _term TERM
|
||||
wait $redis_process $serge_process
|
||||
|
||||
Reference in New Issue
Block a user