Create entrypoint.sh
Browse files- entrypoint.sh +36 -0
entrypoint.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
echo "π Starting Sandbox Server..."
|
| 5 |
+
|
| 6 |
+
# Start Node.js server in background
|
| 7 |
+
echo "π¦ Starting Node.js API server on port 3001..."
|
| 8 |
+
node /app/server.js &
|
| 9 |
+
NODE_PID=$!
|
| 10 |
+
|
| 11 |
+
# Wait for Node.js to be ready
|
| 12 |
+
echo "β³ Waiting for Node.js server to start..."
|
| 13 |
+
sleep 5
|
| 14 |
+
|
| 15 |
+
# Check if Node.js is running
|
| 16 |
+
if ! kill -0 $NODE_PID 2>/dev/null; then
|
| 17 |
+
echo "β Node.js server failed to start"
|
| 18 |
+
exit 1
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
echo "β
Node.js server started successfully"
|
| 22 |
+
|
| 23 |
+
# Test Nginx configuration
|
| 24 |
+
echo "π Testing Nginx configuration..."
|
| 25 |
+
nginx -t
|
| 26 |
+
|
| 27 |
+
if [ $? -eq 0 ]; then
|
| 28 |
+
echo "β
Nginx configuration is valid"
|
| 29 |
+
else
|
| 30 |
+
echo "β Nginx configuration is invalid"
|
| 31 |
+
exit 1
|
| 32 |
+
fi
|
| 33 |
+
|
| 34 |
+
# Start Nginx in foreground
|
| 35 |
+
echo "π Starting Nginx on port 7860..."
|
| 36 |
+
exec nginx -g "daemon off;"
|