fix: restart.sh 改用 kill -9 强杀并等待端口释放后再启动
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
73cffb704f
commit
3971f8dc19
@ -1,12 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# 重新编译并启动 Flutter Web (localhost:8080)
|
# 重新编译并启动 Flutter Web (localhost:8080)
|
||||||
|
|
||||||
# 杀掉占用 8080 端口的进程
|
# 杀掉占用 8080 端口的进程(强制)
|
||||||
PID=$(lsof -ti:8080 2>/dev/null)
|
PID=$(lsof -ti:8080 2>/dev/null)
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
echo "正在停止旧进程 (PID: $PID)..."
|
echo "正在强制停止旧进程 (PID: $PID)..."
|
||||||
kill $PID 2>/dev/null
|
kill -9 $PID 2>/dev/null
|
||||||
sleep 1
|
# 等待端口真正释放(最多 5 秒)
|
||||||
|
for i in $(seq 1 10); do
|
||||||
|
lsof -ti:8080 > /dev/null 2>&1 || break
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "正在编译并启动 Flutter Web..."
|
echo "正在编译并启动 Flutter Web..."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user