smodusermc commited on
Commit
8c0f94a
·
verified ·
1 Parent(s): fbd30e6

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +41 -49
start.sh CHANGED
@@ -1,78 +1,70 @@
1
  #!/bin/bash
2
 
3
- # Define the log file path using the environment variable from the Dockerfile
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 STEP: Test Agent Execution ---
8
- # Forces the agent to run '--help' to ensure the binary is executable and writes to the log.
9
  echo "==================================================" > "$PLAYIT_LOG_FILE"
10
- echo "Starting PlayIt Agent Execution Test..." >> "$PLAYIT_LOG_FILE"
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
- # Check if the execution test was successful by looking for the 'Usage' string
16
- if grep -q "Usage: playit" "$PLAYIT_LOG_FILE"; then
17
- echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
18
- echo "PlayIt agent execution test SUCCESSFUL (Binary is running)." >> "$PLAYIT_LOG_FILE"
19
- echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
20
- else
21
- # If the test fails, print the error to the log and stop the tunnel process
 
 
 
 
 
 
 
 
 
22
  echo "--------------------------------------------------" >> "$PLAYIT_LOG_FILE"
23
- echo "PlayIt agent execution test FAILED. Check binary permissions or integrity." >> "$PLAYIT_LOG_FILE"
 
 
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
- else
34
- # Only run if the execution test was successful (i.e., we found the 'Usage' string)
35
- if grep -q "SUCCESSFUL" "$PLAYIT_LOG_FILE"; then
36
- echo "Starting PlayIt.gg Agent with secret key..." >> "$PLAYIT_LOG_FILE"
37
- # Run the agent in the background, appending all output to the log file.
38
- /usr/local/bin/playit run --secret-key "$PLAYIT_SECRET_KEY" --api-address 127.0.0.1:9000 >> "$PLAYIT_LOG_FILE" 2>&1 &
39
-
40
- # Wait up to 30 seconds for the tunnel to establish
41
- for i in {1..30}; do
42
- if grep -q ".playit.gg" "$PLAYIT_LOG_FILE"; then
43
- echo "PlayIt.gg tunnel address found! Logs are now complete." >> "$PLAYIT_LOG_FILE"
44
- break
45
- fi
46
- sleep 1
47
- done
48
- fi
49
  fi
50
 
51
 
52
- # --- 2. Display the PlayIt Tunnel Address (if found) ---
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 last few lines for immediate diagnosis in the console log
59
- tail -n 10 "$PLAYIT_LOG_FILE"
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 not found."
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