serge/scripts/dev.sh
Olivier DEBAUCHE f9d8ed2ff1
Add support for IPv6 (#1055)
* 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>
2024-01-18 08:31:22 -05:00

68 lines
1.7 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"
# Install python vendor dependencies
pip install -r /usr/src/app/requirements.txt || {
echo 'Failed to install python dependencies from requirements.txt'
exit 1
}
# Install python dependencies
pip install -e ./api || {
echo 'Failed to install python dependencies'
exit 1
}
# Install python bindings
eval "$pip_command" || {
echo 'Failed to install llama-cpp-python'
exit 1
}
# Start Redis instance
redis-server /etc/redis/redis.conf &
# Start the web server
cd /usr/src/app/web || exit 1
npm run dev -- --host 0.0.0.0 --port 8008 &
# 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" = true ] && hypercorn_cmd+=" --bind [::]:8008"
$hypercorn_cmd || {
echo 'Failed to start main app'
exit 1
}