2023-03-29 04:57:03 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
# Shared environment variables
|
|
|
|
|
export LOGS_DIR="${LOGS_DIR:-/data/logs}"
|
|
|
|
|
export DB_FILE="${DB_FILE:-/data/logs/duckdb/duck.db}"
|
2023-04-03 05:04:04 +00:00
|
|
|
export CONFIG_FILE=${CONFIG_FILE:-/data/config/tabby.toml}
|
2023-03-29 04:57:03 +00:00
|
|
|
|
|
|
|
|
# server
|
|
|
|
|
export MODEL_NAME="${MODEL_NAME:-TabbyML/J-350M}"
|
|
|
|
|
export MODEL_BACKEND="${MODEL_BACKEND:-python}"
|
2023-04-04 03:54:57 +00:00
|
|
|
if [ ! -n "$WEB_CONCURRENCY" ]; then
|
|
|
|
|
# Set WEB_CONCURRENCY for uvicorn workers.
|
|
|
|
|
export WEB_CONCURRENCY=$(nproc --all)
|
|
|
|
|
fi
|
2023-03-29 04:57:03 +00:00
|
|
|
|
2023-04-03 05:04:04 +00:00
|
|
|
# projects
|
|
|
|
|
export GIT_REPOSITORIES_DIR="${REPOSITORIES_DIR:-/data/repositories}"
|
|
|
|
|
export DATASET_DIR="${REPOSITORIES_DIR:-/data/dataset}"
|
|
|
|
|
|
2023-03-29 04:57:03 +00:00
|
|
|
# dagu
|
|
|
|
|
export DAGU_DAGS="tabby/tasks"
|
|
|
|
|
|
|
|
|
|
init() {
|
2023-04-03 05:04:04 +00:00
|
|
|
if [ ! -f $CONFIG_FILE ]; then
|
|
|
|
|
mkdir -p $(dirname $CONFIG_FILE)
|
|
|
|
|
touch $CONFIG_FILE
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Disable safe directory check
|
|
|
|
|
git config --global --add safe.directory '*'
|
|
|
|
|
|
2023-03-29 04:57:03 +00:00
|
|
|
python -m tabby.tools.download_models --repo_id=$MODEL_NAME
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
supervisor() {
|
2023-04-05 12:19:43 +00:00
|
|
|
if [[ "$MODEL_BACKEND" == "triton" ]]
|
|
|
|
|
then
|
|
|
|
|
|
|
|
|
|
local TRITON_SERVER=$(cat <<EOF
|
|
|
|
|
[program:triton]
|
|
|
|
|
command=triton.sh
|
|
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
2023-03-29 04:57:03 +00:00
|
|
|
supervisord -n -c <(cat <<EOF
|
|
|
|
|
[supervisord]
|
2023-04-05 12:19:43 +00:00
|
|
|
logfile = ${LOGS_DIR}/supervisord.log
|
2023-03-29 04:57:03 +00:00
|
|
|
loglevel = debug
|
|
|
|
|
|
|
|
|
|
[program:server]
|
|
|
|
|
command=uvicorn tabby.server:app --host 0.0.0.0 --port 5000
|
|
|
|
|
|
|
|
|
|
[program:admin]
|
2023-04-04 12:01:44 +00:00
|
|
|
command=streamlit run tabby/admin/Home.py --server.port 8501 --theme.base=dark
|
2023-03-29 04:57:03 +00:00
|
|
|
|
|
|
|
|
[program:vector]
|
2023-04-04 11:53:22 +00:00
|
|
|
command=vector --config-toml tabby/config/vector.toml
|
2023-03-29 04:57:03 +00:00
|
|
|
|
|
|
|
|
[program:dagu_scheduler]
|
|
|
|
|
command=dagu scheduler
|
|
|
|
|
|
|
|
|
|
[program:dagu_server]
|
|
|
|
|
command=dagu server --host 0.0.0.0 --port 8080
|
2023-04-05 12:19:43 +00:00
|
|
|
|
|
|
|
|
$TRITON_SERVER
|
2023-03-29 04:57:03 +00:00
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init
|
|
|
|
|
supervisor
|