【发布时间】:2020-02-26 19:22:53
【问题描述】:
为了测试,我尝试在 docker 内运行 gcloud devserver 并附上该注释:
sudo /usr/local/gcloud/google-cloud-sdk/bin/java_dev_appserver.sh --disable_update_check --port=8888 --help /app/target/qdacity-war/ 2>&1 | sudo tee /app/logs/devserver.log > /dev/null &
为了检查开发服务器是否启动成功,我使用了这个脚本:
#!/bin/bash
# This script waits until the port 8888 is open.
SERVER=localhost
PORT=8888
TIMEOUT=180
TIME_INTERVAL=2
PORT_OPEN=1
PORT_CLOSED=0
time=0
isPortOpen=0
while [ $time -lt $TIMEOUT ] && [ $isPortOpen -eq $PORT_CLOSED ];
do
# Connect to the port
(echo > /dev/tcp/$SERVER/$PORT) >/dev/null 2>&1
if [ $? -ne 0 ]; then
isPortOpen=$PORT_CLOSED
else
isPortOpen=$PORT_OPEN
fi
time=$(($time+$TIME_INTERVAL))
sleep $TIME_INTERVAL
done
if [ $isPortOpen -eq $PORT_OPEN ]; then
echo "Port is open after ${time} seconds."
# Give the server more time to properly start
sleep 10
else
echo "Reached the timeout (${TIMEOUT} seconds). The port ${SERVER}:${PORT} is not available."
exit 1
fi
跑完所有的测试,我才回来:
Reached the timeout (180 seconds). The port localhost:8888 is not available.
我无法确定启动开发服务器或查询端口是否有任何问题。 有没有人有想法或解决方案? 谢谢!
【问题讨论】:
-
lsof -i :8888的输出是什么?这应该为您提供当前正在该端口上侦听的任何进程的进程 ID (PID)。 -
您是否尝试过使用其他端口运行您的应用服务器?
-
@Gerb 谢谢,我使用了“sudo lsof -i :8888”,但没有得到任何输出,没有表格或错误:/
-
@AndresS 谢谢,但是更改端口会导致相同的结果。