* Update deploy.sh add support ipv6 * Update dev.sh add support for ipv6 * Update deploy.sh add support for ipv6 * Update deploy.sh add support for ipv6 * Update dev.sh support for ipv6 * Update dev.sh support for ipv6 reworked Thanks Gaby :) * Update serge.env add support for ipv6 * Update deploy.sh support for ipv6 reworked Thanks Gaby :) * Update deploy.sh bugfix * Update serge.env * Update serge.env rename variable in SERGE_ENABLE_IPV6 * Update deploy.sh rename variable in SERGE_ENABLE_IPV6 * Update dev.sh rename variable in SERGE_ENABLE_IPV6 * Update deploy.sh remove redudant code * Update dev.sh add missing code * Update deploy.sh tiny change * Update dev.sh bugfix * Update deploy.sh bugfix * Update dev.sh bugfix * Update deploy.sh change unicorn by hypercorn * Update serge.env delete unecessary param * Update dev.sh replace unicorn by hypercorn * Update pyproject.toml replace unicorn by hypercorn * Update poetry.lock replace unicorn by hypercorn * Update poetry.lock poetry updated * Update pyproject.toml update * Update poetry.lock hypercorn update * Update deploy.sh shmft applied * Update dev.sh shmft applied * Update deploy.sh shmft applied * Update dev.sh shmft applied * Update dev.sh bugfix * Update serge.env missing value * Update deploy.sh code corrected * Update dev.sh code corrected * Update serge.env code corrected * Update deploy.sh rollback * Update dev.sh rollback * Update serge.env * Update deploy.sh add SERGE_IPV6_SUPPORT * Update dev.sh Add SERGE_IPV6_SUPPORT * Update dev.sh * Update deploy.sh --------- Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
66 lines
1.6 KiB
Bash
Executable File
66 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -x
|
|
source serge.env
|
|
|
|
# Get CPU Architecture
|
|
cpu_arch=$(uname -m)
|
|
|
|
# Function to detect CPU features
|
|
detect_cpu_features() {
|
|
cpu_info=$(lscpu)
|
|
if echo "$cpu_info" | grep -q "avx512"; then
|
|
echo "AVX512"
|
|
elif echo "$cpu_info" | grep -q "avx2"; then
|
|
echo "AVX2"
|
|
elif echo "$cpu_info" | grep -q "avx"; then
|
|
echo "AVX"
|
|
else
|
|
echo "basic"
|
|
fi
|
|
}
|
|
|
|
# Check if the CPU architecture is aarch64/arm64
|
|
if [ "$cpu_arch" = "aarch64" ]; then
|
|
pip_command="python -m pip install -v llama-cpp-python==$LLAMA_PYTHON_VERSION --only-binary=:all: --extra-index-url=https://gaby.github.io/arm64-wheels/"
|
|
else
|
|
# Use @jllllll provided wheels
|
|
cpu_feature=$(detect_cpu_features)
|
|
pip_command="python -m pip install -v llama-cpp-python==$LLAMA_PYTHON_VERSION --only-binary=:all: --extra-index-url=https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/$cpu_feature/cpu"
|
|
fi
|
|
|
|
echo "Recommended install command for llama-cpp-python: $pip_command"
|
|
|
|
# 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
|
|
eval "$pip_command" || {
|
|
echo 'Failed to install llama-cpp-python'
|
|
exit 1
|
|
}
|
|
|
|
# Start Redis instance
|
|
redis-server /etc/redis/redis.conf &
|
|
redis_process=$!
|
|
|
|
# Start the API
|
|
cd /usr/src/app/api || exit 1
|
|
hypercorn_cmd="hypercorn src.serge.main:app --bind 0.0.0.0:8008"
|
|
[ "$SERGE_ENABLE_IPV6" = false ] && hypercorn_cmd+=" --bind [::]:8008"
|
|
|
|
$hypercorn_cmd || {
|
|
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
|