fix bug
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 3m48s

This commit is contained in:
repair-agent 2026-03-03 15:33:00 +08:00
parent 01b2ef298c
commit 5e3f0653c9
3 changed files with 23 additions and 14 deletions

View File

@ -28,7 +28,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
FROM alpine:3.20 FROM alpine:3.20
RUN sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories && \ RUN sed -i 's#dl-cdn.alpinelinux.org#mirrors.aliyun.com#g' /etc/apk/repositories && \
apk add --no-cache opus ffmpeg ca-certificates && \ apk add --no-cache opus opusfile ffmpeg ca-certificates && \
addgroup -S hwws && adduser -S hwws -G hwws addgroup -S hwws && adduser -S hwws -G hwws
COPY --from=builder /app/hw-ws-service /hw-ws-service COPY --from=builder /app/hw-ws-service /hw-ws-service

View File

@ -98,6 +98,11 @@ func (s *Server) Shutdown(ctx context.Context) {
// handleConn 处理单个 WebSocket 连接的完整生命周期。 // handleConn 处理单个 WebSocket 连接的完整生命周期。
// URL 格式:/xiaozhi/v1/?device-id=<MAC>&client-id=<UUID> // URL 格式:/xiaozhi/v1/?device-id=<MAC>&client-id=<UUID>
func (s *Server) handleConn(w http.ResponseWriter, r *http.Request) { func (s *Server) handleConn(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/xiaozhi/v1/healthz" {
s.handleStatus(w, r)
return
}
deviceID := r.URL.Query().Get("device-id") deviceID := r.URL.Query().Get("device-id")
clientID := r.URL.Query().Get("client-id") clientID := r.URL.Query().Get("client-id")

30
run.sh
View File

@ -44,21 +44,25 @@ echo "[✓] 虚拟环境就绪"
free_port() { free_port() {
local port=$1 local port=$1
local name=$2 local name=$2
local pid local pids
pid=$(lsof -ti :"$port" 2>/dev/null) pids=$(lsof -ti :"$port" 2>/dev/null)
if [ -n "$pid" ]; then if [ -z "$pids" ]; then
echo "[!] 端口 $port ($name) 被占用PID: $pid,正在终止..."
kill -9 "$pid" 2>/dev/null
sleep 1
pid=$(lsof -ti :"$port" 2>/dev/null)
if [ -n "$pid" ]; then
echo "[x] 端口 $port 释放失败,请手动处理"
exit 1
fi
echo "[✓] 端口 $port 已释放"
else
echo "[✓] 端口 $port 空闲" echo "[✓] 端口 $port 空闲"
return
fi fi
echo "[!] 端口 $port ($name) 被占用PID: $pids,正在终止..."
echo "$pids" | xargs kill -9 2>/dev/null
for i in 1 2 3; do
sleep 1
pids=$(lsof -ti :"$port" 2>/dev/null)
[ -z "$pids" ] && break
echo "$pids" | xargs kill -9 2>/dev/null
done
if [ -n "$(lsof -ti :"$port" 2>/dev/null)" ]; then
echo "[x] 端口 $port 释放失败,请手动处理"
exit 1
fi
echo "[✓] 端口 $port 已释放"
} }
free_port "$DJANGO_PORT" "Django" free_port "$DJANGO_PORT" "Django"