mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-10-27 08:21:30 +00:00
webui: Remove running llama-server within WebUI dev.sh script (#16363)
This commit is contained in:
committed by
GitHub
parent
e74c92e842
commit
aa9538a63a
@@ -1,5 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Development script for llama.cpp webui
|
||||
#
|
||||
# This script starts the webui development servers (Storybook and Vite).
|
||||
# Note: You need to start llama-server separately.
|
||||
#
|
||||
# Usage:
|
||||
# bash scripts/dev.sh
|
||||
# npm run dev
|
||||
|
||||
cd ../../../
|
||||
|
||||
# Check and install git hooks if missing
|
||||
@@ -28,76 +37,19 @@ check_and_install_hooks() {
|
||||
# Install git hooks if needed
|
||||
check_and_install_hooks
|
||||
|
||||
# Check if llama-server binary already exists
|
||||
if [ ! -f "build/bin/llama-server" ]; then
|
||||
echo "Building llama-server..."
|
||||
cmake -B build && cmake --build build --config Release -t llama-server
|
||||
else
|
||||
echo "llama-server binary already exists, skipping build."
|
||||
fi
|
||||
|
||||
# Start llama-server and capture output
|
||||
echo "Starting llama-server..."
|
||||
mkfifo server_output.pipe
|
||||
build/bin/llama-server -hf ggml-org/gpt-oss-20b-GGUF --jinja -c 0 --no-webui > server_output.pipe 2>&1 &
|
||||
SERVER_PID=$!
|
||||
|
||||
# Function to wait for server to be ready
|
||||
wait_for_server() {
|
||||
echo "Waiting for llama-server to be ready..."
|
||||
local max_wait=60
|
||||
local start_time=$(date +%s)
|
||||
|
||||
# Read server output in background and look for the ready message
|
||||
(
|
||||
while IFS= read -r line; do
|
||||
echo "🔍 Server: $line"
|
||||
if [[ "$line" == *"server is listening on http://127.0.0.1:8080 - starting the main loop"* ]]; then
|
||||
echo "✅ llama-server is ready!"
|
||||
echo "READY" > server_ready.flag
|
||||
break
|
||||
fi
|
||||
done < server_output.pipe
|
||||
) &
|
||||
|
||||
# Wait for ready flag or timeout
|
||||
while [ ! -f server_ready.flag ]; do
|
||||
local current_time=$(date +%s)
|
||||
local elapsed=$((current_time - start_time))
|
||||
|
||||
if [ $elapsed -ge $max_wait ]; then
|
||||
echo "❌ Server failed to start within $max_wait seconds"
|
||||
rm -f server_ready.flag
|
||||
return 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
rm -f server_ready.flag
|
||||
return 0
|
||||
}
|
||||
|
||||
# Cleanup function
|
||||
cleanup() {
|
||||
echo "🧹 Cleaning up..."
|
||||
kill $SERVER_PID 2>/dev/null
|
||||
rm -f server_output.pipe server_ready.flag
|
||||
exit
|
||||
}
|
||||
|
||||
# Set up signal handlers
|
||||
trap cleanup SIGINT SIGTERM
|
||||
|
||||
# Wait for server to be ready
|
||||
if wait_for_server; then
|
||||
echo "🚀 Starting development servers..."
|
||||
echo "📝 Note: Make sure to start llama-server separately if needed"
|
||||
cd tools/server/webui
|
||||
storybook dev -p 6006 --ci & vite dev --host 0.0.0.0 &
|
||||
|
||||
# Wait for all background processes
|
||||
wait
|
||||
else
|
||||
echo "❌ Failed to start development environment"
|
||||
cleanup
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user