Spaces:
Build error
Build error
Update start.sh
Browse files
start.sh
CHANGED
|
@@ -1,78 +1,70 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
# Define the log file path
|
| 4 |
-
# This ensures consistency with the Python application's logging display.
|
| 5 |
PLAYIT_LOG_FILE="${MINECRAFT_SERVER_DIR}/playit_error.log"
|
| 6 |
|
| 7 |
-
# --- CRITICAL TROUBLESHOOTING
|
| 8 |
-
|
| 9 |
echo "==================================================" > "$PLAYIT_LOG_FILE"
|
| 10 |
-
echo "
|
| 11 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
| 12 |
-
# Execute playit with '--help' and capture all output (stdout and stderr)
|
| 13 |
-
/usr/local/bin/playit --help >> "$PLAYIT_LOG_FILE" 2>&1
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
| 23 |
-
echo "PlayIt
|
|
|
|
|
|
|
| 24 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
| 25 |
-
# Skip running the agent since the binary is broken
|
| 26 |
fi
|
| 27 |
-
# --- END TROUBLESHOOTING STEP ---
|
| 28 |
|
|
|
|
| 29 |
|
| 30 |
# --- 1. Start PlayIt.gg Agent in the background ---
|
| 31 |
if [ -z "$PLAYIT_SECRET_KEY" ]; then
|
| 32 |
echo "WARNING: PLAYIT_SECRET_KEY is not set. PlayIt tunnel will not start." >> "$PLAYIT_LOG_FILE"
|
| 33 |
-
|
| 34 |
-
# Only
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
sleep 1
|
| 47 |
-
done
|
| 48 |
-
fi
|
| 49 |
fi
|
| 50 |
|
| 51 |
|
| 52 |
-
# --- 2. Display the PlayIt Tunnel Address (
|
| 53 |
-
# This part is for the console output when the app starts
|
| 54 |
echo "=================================================="
|
| 55 |
echo "PLAYIT.GG LOGS (Tunnel Address):"
|
| 56 |
-
|
| 57 |
if [ -f "$PLAYIT_LOG_FILE" ]; then
|
| 58 |
-
# Print the
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
# Filter for the tunnel URL or relevant addresses in the console output
|
| 62 |
-
TUNNEL_ADDRESS=$(grep -E "available_addresses" "$PLAYIT_LOG_FILE" | head -n 1)
|
| 63 |
-
if [ -n "$TUNNEL_ADDRESS" ]; then
|
| 64 |
-
echo "---"
|
| 65 |
-
echo "Found Tunnel: $TUNNEL_ADDRESS"
|
| 66 |
-
else
|
| 67 |
-
echo "Tunnel address not yet available or failed to start."
|
| 68 |
-
fi
|
| 69 |
else
|
| 70 |
-
echo "PlayIt.gg Agent log file
|
| 71 |
fi
|
| 72 |
echo "=================================================="
|
| 73 |
|
| 74 |
|
| 75 |
# --- 3. Start the main Python Application (Flask + Minecraft) ---
|
| 76 |
echo "Starting main Python application (app.py)..."
|
| 77 |
-
# The 'exec' command replaces the current shell process with the python process
|
| 78 |
exec python app.py
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
+
# Define the log file path
|
|
|
|
| 4 |
PLAYIT_LOG_FILE="${MINECRAFT_SERVER_DIR}/playit_error.log"
|
| 5 |
|
| 6 |
+
# --- CRITICAL TROUBLESHOOTING: Binary Check & Immediate Failure Capture ---
|
| 7 |
+
|
| 8 |
echo "==================================================" > "$PLAYIT_LOG_FILE"
|
| 9 |
+
echo "STARTING PLAYIT AGENT DIAGNOSTICS" >> "$PLAYIT_LOG_FILE"
|
| 10 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
# 1. Use 'file' command to check if the binary is valid
|
| 13 |
+
echo "1. Checking binary file type..." >> "$PLAYIT_LOG_FILE"
|
| 14 |
+
file /usr/local/bin/playit >> "$PLAYIT_LOG_FILE" 2>&1
|
| 15 |
+
|
| 16 |
+
# 2. Check execution permissions
|
| 17 |
+
echo "2. Checking permissions and ownership..." >> "$PLAYIT_LOG_FILE"
|
| 18 |
+
ls -l /usr/local/bin/playit >> "$PLAYIT_LOG_FILE" 2>&1
|
| 19 |
+
|
| 20 |
+
# 3. CRITICAL: Try running a minimal command and capture the exit code
|
| 21 |
+
echo "3. Testing basic execution and exit code..." >> "$PLAYIT_LOG_FILE"
|
| 22 |
+
# Run with exec to capture any immediate low-level crash (e.g., missing library)
|
| 23 |
+
/usr/local/bin/playit --version > /dev/null 2>&1
|
| 24 |
+
EXEC_STATUS=$?
|
| 25 |
+
echo "Exit Status of 'playit --version': $EXEC_STATUS" >> "$PLAYIT_LOG_FILE"
|
| 26 |
+
|
| 27 |
+
if [ "$EXEC_STATUS" -ne 0 ]; then
|
| 28 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
| 29 |
+
echo "FATAL: PlayIt binary failed to execute (Exit Code: $EXEC_STATUS)." >> "$PLAYIT_LOG_FILE"
|
| 30 |
+
echo "This indicates a corrupted file, missing shared library, or wrong architecture." >> "$PLAYIT_LOG_FILE"
|
| 31 |
+
echo "PlayIt setup aborted." >> "$PLAYIT_LOG_FILE"
|
| 32 |
echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
|
|
|
|
| 33 |
fi
|
|
|
|
| 34 |
|
| 35 |
+
# --- End Troubleshooting ---
|
| 36 |
|
| 37 |
# --- 1. Start PlayIt.gg Agent in the background ---
|
| 38 |
if [ -z "$PLAYIT_SECRET_KEY" ]; then
|
| 39 |
echo "WARNING: PLAYIT_SECRET_KEY is not set. PlayIt tunnel will not start." >> "$PLAYIT_LOG_FILE"
|
| 40 |
+
elif [ "$EXEC_STATUS" -eq 0 ]; then
|
| 41 |
+
# Only proceed if the basic execution test passed
|
| 42 |
+
echo "Starting PlayIt.gg Agent with 'run' command..." >> "$PLAYIT_LOG_FILE"
|
| 43 |
+
/usr/local/bin/playit run --secret-key "$PLAYIT_SECRET_KEY" --api-address 127.0.0.1:9000 >> "$PLAYIT_LOG_FILE" 2>&1 &
|
| 44 |
+
|
| 45 |
+
# Wait for tunnel establishment
|
| 46 |
+
for i in {1..30}; do
|
| 47 |
+
if grep -q ".playit.gg" "$PLAYIT_LOG_FILE"; then
|
| 48 |
+
echo "PlayIt.gg tunnel address found! Logs are now complete." >> "$PLAYIT_LOG_FILE"
|
| 49 |
+
break
|
| 50 |
+
fi
|
| 51 |
+
sleep 1
|
| 52 |
+
done
|
|
|
|
|
|
|
|
|
|
| 53 |
fi
|
| 54 |
|
| 55 |
|
| 56 |
+
# --- 2. Display the PlayIt Tunnel Address (in the main console) ---
|
|
|
|
| 57 |
echo "=================================================="
|
| 58 |
echo "PLAYIT.GG LOGS (Tunnel Address):"
|
|
|
|
| 59 |
if [ -f "$PLAYIT_LOG_FILE" ]; then
|
| 60 |
+
# Print the full log contents for immediate diagnosis
|
| 61 |
+
cat "$PLAYIT_LOG_FILE"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
else
|
| 63 |
+
echo "PlayIt.gg Agent log file was never created."
|
| 64 |
fi
|
| 65 |
echo "=================================================="
|
| 66 |
|
| 67 |
|
| 68 |
# --- 3. Start the main Python Application (Flask + Minecraft) ---
|
| 69 |
echo "Starting main Python application (app.py)..."
|
|
|
|
| 70 |
exec python app.py
|