#!/bin/sh
set -e

# 自动找到 server 的入口文件
ENTRY_FILE=$(find /app/server -type f -name 'index.js' -o -name 'app.js' | head -n 1)

if [ -z "$ENTRY_FILE" ]; then
  echo "No server entry file found in /app/server!"
  exit 1
fi

echo "Starting Node.js backend: $ENTRY_FILE"
node $ENTRY_FILE &

echo "Starting Nginx..."
nginx -g 'daemon off;'
