Files
frontend_v2/entrypoint.sh
toom1996 335e264e45 update
2026-09-29 19:59:22 +08:00

19 lines
627 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# 前端运行期入口:同容器内先后拉起
# 1) node standalone server(Astro 构建产物,监听 127.0.0.1:3000,承载 SSR 详情页/静态资源)
# 2) nginx(监听 80,反代 / 到 node、/api 到 backend:8090)
set -e
# node server 后台运行;一旦退出,整个容器随之退出(便于编排器感知故障)
node ./dist/server/entry.mjs &
NODE_PID=$!
# 捕获 SIGTERM/SIGINT 优雅关闭 node 与 nginx
trap 'kill -TERM $NODE_PID 2>/dev/null; nginx -s stop 2>/dev/null; exit 0' TERM INT
# nginx 前台运行(容器主进程)
nginx -g 'daemon off;' &
NGINX_PID=$!
wait -n