fix bug
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 3m48s
All checks were successful
Build and Deploy Backend / build-and-deploy (push) Successful in 3m48s
This commit is contained in:
parent
01b2ef298c
commit
5e3f0653c9
@ -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
|
||||||
|
|||||||
@ -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")
|
||||||
|
|
||||||
|
|||||||
24
run.sh
24
run.sh
@ -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,正在终止..."
|
echo "[✓] 端口 $port 空闲"
|
||||||
kill -9 "$pid" 2>/dev/null
|
return
|
||||||
|
fi
|
||||||
|
echo "[!] 端口 $port ($name) 被占用,PID: $pids,正在终止..."
|
||||||
|
echo "$pids" | xargs kill -9 2>/dev/null
|
||||||
|
for i in 1 2 3; do
|
||||||
sleep 1
|
sleep 1
|
||||||
pid=$(lsof -ti :"$port" 2>/dev/null)
|
pids=$(lsof -ti :"$port" 2>/dev/null)
|
||||||
if [ -n "$pid" ]; then
|
[ -z "$pids" ] && break
|
||||||
|
echo "$pids" | xargs kill -9 2>/dev/null
|
||||||
|
done
|
||||||
|
if [ -n "$(lsof -ti :"$port" 2>/dev/null)" ]; then
|
||||||
echo "[x] 端口 $port 释放失败,请手动处理"
|
echo "[x] 端口 $port 释放失败,请手动处理"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "[✓] 端口 $port 已释放"
|
echo "[✓] 端口 $port 已释放"
|
||||||
else
|
|
||||||
echo "[✓] 端口 $port 空闲"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free_port "$DJANGO_PORT" "Django"
|
free_port "$DJANGO_PORT" "Django"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user