Commit 2b4a3ca3 by Ivan

fix; healthy check

parent 5d1112df
......@@ -23,6 +23,7 @@ RUN apt-get update -qq && \
git \
build-essential \
pkg-config \
ca-certificates \
&& rm -rf /var/lib/apt/lists /var/cache/apt/archives
# Set production environment and optimize memory usage
......@@ -71,5 +72,10 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start server via Rails default port 3000
EXPOSE 3000
# 添加健康检查,使用简单的curl请求检查应用是否响应
HEALTHCHECK --interval=5s --timeout=3s --start-period=30s --retries=3 \
CMD curl -f http://localhost:3000/ || exit 1
# 使用正确的路径启动Rails服务器,并指定端口为3000
CMD ["/rails/code/bin/rails", "server", "-p", "3000", "-b", "0.0.0.0"]
......@@ -274,6 +274,21 @@ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
echo "No package.json found in /rails, skipping npm install"
fi
# 添加健康检查相关的调试信息
echo "Setting up health check monitoring..."
# 创建一个后台进程来监控应用的健康状态
(
while true; do
echo "[Health Check] Checking application status..."
if curl -s http://localhost:3000/ >/dev/null 2>&1; then
echo "[Health Check] Application is responding!"
else
echo "[Health Check] Application is not responding yet."
fi
sleep 10
done
) &
# Prepare database files with proper permissions
echo "Ensuring database files exist with proper permissions..."
......
......@@ -129,14 +129,23 @@ volumes:
asset_path: false
# Deployment configuration for better reliability
# Increase the time to wait for a container to become ready
deploy_timeout: 60
# # Increase the time to wait for a container to drain
# drain_timeout: 60
# # Increase the time to wait for a container to boot after it is running
# readiness_delay: 30
# 增加部署超时时间,给应用更多时间启动
deploy_timeout: 180
# 增加容器排水超时时间
drain_timeout: 60
# 增加容器启动后的就绪延迟
readiness_delay: 30
# 配置健康检查参数
health_check:
# 健康检查超时时间
timeout: 5
# 健康检查间隔
interval: 5
# 健康检查重试次数
retries: 12
# Note: Run the setup script manually before deployment:
# scp ./bin/setup_volumes.sh root@45.78.59.154:/root/setup_volumes.sh
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment