-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathllama-server.sh
More file actions
executable file
·50 lines (36 loc) · 977 Bytes
/
Copy pathllama-server.sh
File metadata and controls
executable file
·50 lines (36 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env sh
set -eux
model_alias() {
model="$1"
if [ -z "$model" ]; then
echo
return
fi
repo_model="${model%/*}"
file="${model##*/}"
file="${file%.gguf}"
prefix="${repo_model##*/}"
prefix="${prefix%-GGUF}"
printf '%s:%s\n' "$repo_model" "${file#"$prefix"-}"
}
if [ ! -f /models/.initialized ]; then
cp -r /usr/share/llama/models/. /models
touch /models/.initialized
fi
LLAMA_MODEL_ALIAS=$(model_alias "${LLAMA_MODEL_PATH}")
/app/llama-server \
--host 0.0.0.0 --port 8080 \
--model "${LLAMA_MODEL_PATH}" \
--alias "${LLAMA_MODEL_ALIAS}" \
"$@" &
LLAMA_PID=$!
socat OPENSSL-LISTEN:8443,reuseaddr,fork,\
cert=/certs/wildcard.pem,key=/certs/wildcard-key.pem,\
verify=0 TCP:127.0.0.1:8080 &
SOCAT_PID=$!
cleanup() {
kill "$SOCAT_PID" "$LLAMA_PID" 2>/dev/null || true
wait "$SOCAT_PID" "$LLAMA_PID" 2>/dev/null || true
}
trap cleanup INT TERM EXIT
wait "$LLAMA_PID" "$SOCAT_PID"