File size: 2,385 Bytes
d7df88d 4559db5 d7df88d 4559db5 d7df88d d31504f 4559db5 d7df88d 4559db5 d31504f 4559db5 d31504f 4559db5 d31504f 4559db5 d31504f 4559db5 d31504f 4559db5 d31504f d7df88d 4559db5 d31504f 4559db5 d31504f 4559db5 d31504f d7df88d 4559db5 d31504f 4559db5 d7df88d 4559db5 d7df88d 4559db5 d7df88d 4559db5 d7df88d f927dd0 d31504f f927dd0 4559db5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
#!/bin/bash
set -e
echo "==== Server Initialization ===="
# --- Start background service ---
echo ">> Configuring network connectivity..."
if [ -z "$PLAYIT_SECRET" ]; then
echo "⚠️ Network configuration not set"
echo " Add configuration in Space Settings -> Secrets"
else
echo "✅ Network config detected"
PLAYIT_CMD=$(which playit || echo "/usr/bin/playit")
if [ -f "$PLAYIT_CMD" ]; then
echo "✅ Starting network service"
$PLAYIT_CMD --secret "$PLAYIT_SECRET" > /dev/null 2>&1 &
PLAYIT_PID=$!
sleep 5
if ps -p $PLAYIT_PID >/dev/null 2>&1; then
echo "✅ Network service active"
else
echo "⚠️ Service not running"
fi
else
echo "⚠️ Network tools unavailable"
fi
fi
# --- Server Configuration ---
echo ">> Setting up server environment..."
if [ -f "server.properties" ]; then
sed -i "s/^server-port=.*/server-port=7860/" server.properties
sed -i "s/^query.port=.*/query.port=7860/" server.properties
echo "✅ Port configured: 7860"
else
echo "⚠️ Using default configuration"
fi
# --- Data Setup ---
echo ">> Loading world data..."
if command -v python3 >/dev/null 2>&1 && [ -f "download_world.py" ]; then
python3 download_world.py || echo "⚠️ Using default world"
else
echo "ℹ️ No custom data found"
fi
chmod -R 777 /app/world* 2>/dev/null || true
chmod -R 777 /app/plugins 2>/dev/null || true
echo "Available data folders:"
ls -la /app/ | grep world || echo "No custom data - generating new"
# --- Start Main Service ---
echo ">> Starting main service on port 7860..."
echo ">> Java: $(java -version 2>&1 | head -n 1)"
echo ">> Memory: 8GB allocated"
exec java -server -Xmx8G -Xms8G \
-XX:+UseG1GC \
-XX:+ParallelRefProcEnabled \
-XX:MaxGCPauseMillis=50 \
-XX:+UnlockExperimentalVMOptions \
-XX:+DisableExplicitGC \
-XX:+AlwaysPreTouch \
-XX:G1NewSizePercent=20 \
-XX:G1MaxNewSizePercent=40 \
-XX:G1HeapRegionSize=8M \
-XX:G1ReservePercent=10 \
-XX:G1HeapWastePercent=5 \
-XX:G1MixedGCCountTarget=4 \
-XX:InitiatingHeapOccupancyPercent=15 \
-XX:G1MixedGCLiveThresholdPercent=85 \
-XX:G1RSetUpdatingPauseTimePercent=5 \
-XX:SurvivorRatio=32 \
-XX:+PerfDisableSharedMem \
-XX:MaxTenuringThreshold=1 \
-jar purpur.jar --nogui |