You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
1.0 KiB

#!/bin/sh
PORT=${PORT:-9876}
if ! [ "$PORT" -ge 1 ] 2>/dev/null || ! [ "$PORT" -le 65535 ] 2>/dev/null; then
echo "Warning: Invalid PORT '$PORT', using default 9876"
PORT=9876
fi
echo "Starting SvelteKit Node.js server on port $PORT..."
# Check if build directory exists
if [ ! -d "/app/build" ]; then
echo "ERROR: Build directory not found at /app/build"
exit 1
fi
# Check if server entry point exists
if [ ! -f "/app/build/index.js" ] && [ ! -f "/app/build/server.js" ]; then
echo "ERROR: Server entry point not found. Expected /app/build/index.js or /app/build/server.js"
echo "Build directory contents:"
ls -la /app/build/
exit 1
fi
# Determine server entry point
SERVER_FILE="/app/build/index.js"
if [ ! -f "$SERVER_FILE" ]; then
SERVER_FILE="/app/build/server.js"
fi
echo "Using server file: $SERVER_FILE"
echo "Working directory: $(pwd)"
echo "Node version: $(node --version)"
echo "NPM version: $(npm --version)"
# Set PORT environment variable for the Node.js server
export PORT
# Start the Node.js server
exec node "$SERVER_FILE"