y59 commited on
Commit
76ff187
·
verified ·
1 Parent(s): cc364ce

Update startup.sh

Browse files
Files changed (1) hide show
  1. startup.sh +82 -35
startup.sh CHANGED
@@ -19,24 +19,7 @@ export HOME=/tmp
19
  export STREMIO_USER_DATA_DIR=/tmp/.stremio-server
20
  export NO_CORS=1
21
  export CASTING_DISABLED=1
22
-
23
- # Find stremio-web-service-run.sh
24
- echo "Searching for Stremio server script..."
25
- STREMIO_SCRIPT=$(find / -name stremio-web-service-run.sh 2>/dev/null | head -1)
26
-
27
- if [ -z "$STREMIO_SCRIPT" ]; then
28
- echo "WARNING: Could not find stremio-web-service-run.sh"
29
- echo "Listing files in root directory:"
30
- ls -la /
31
- echo "Looking for other stremio files:"
32
- find / -name "*stremio*" 2>/dev/null | head -20
33
-
34
- echo "FALLBACK: Using proxy-only mode"
35
- node /app/proxy-only.js
36
- exit 0
37
- fi
38
-
39
- echo "Found Stremio script at: $STREMIO_SCRIPT"
40
 
41
  # Start proxy first to ensure Hugging Face health checks work
42
  echo "Starting proxy server on port 7860..."
@@ -44,25 +27,89 @@ node /app/proxy.js &
44
  PROXY_PID=$!
45
  echo "Proxy started with PID: $PROXY_PID"
46
 
47
- # Slight delay before starting Stremio
48
- sleep 2
 
 
 
 
 
 
 
 
 
 
49
 
50
- # Start Stremio server if script was found
51
- echo "Starting Stremio server on port 11470 using $STREMIO_SCRIPT..."
52
- chmod +x "$STREMIO_SCRIPT"
53
- "$STREMIO_SCRIPT" &
54
- STREMIO_PID=$!
55
 
56
- if [ $? -ne 0 ]; then
57
- echo "ERROR: Failed to start Stremio server"
58
- echo "Terminating proxy..."
59
- kill $PROXY_PID
 
 
 
 
 
60
 
61
- echo "FALLBACK: Using proxy-only mode"
62
- exec node /app/proxy-only.js
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  else
64
- echo "Stremio server started with PID: $STREMIO_PID"
65
- # Keep container running
66
- echo "Services started, monitoring processes..."
67
- wait
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  fi
 
19
  export STREMIO_USER_DATA_DIR=/tmp/.stremio-server
20
  export NO_CORS=1
21
  export CASTING_DISABLED=1
22
+ export APP_PATH=/tmp/.stremio-server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  # Start proxy first to ensure Hugging Face health checks work
25
  echo "Starting proxy server on port 7860..."
 
27
  PROXY_PID=$!
28
  echo "Proxy started with PID: $PROXY_PID"
29
 
30
+ # Find stremio-web-service-run.sh
31
+ echo "Searching for Stremio server script..."
32
+ STREMIO_SCRIPT=$(find / -name stremio-web-service-run.sh 2>/dev/null | head -1)
33
+
34
+ # Try different methods to start Stremio server
35
+ if [ -z "$STREMIO_SCRIPT" ]; then
36
+ echo "WARNING: Could not find stremio-web-service-run.sh"
37
+ echo "Trying minimal Node.js starter instead..."
38
+ node /app/stremio-minimal.js &
39
+ STREMIO_PID=$!
40
+ else
41
+ echo "Found Stremio script at: $STREMIO_SCRIPT"
42
 
43
+ # Try to run the script directly with sh
44
+ echo "Starting Stremio server on port 11470..."
45
+ sh "$STREMIO_SCRIPT" &
46
+ STREMIO_PID=$!
47
+ fi
48
 
49
+ # Check if Stremio started correctly
50
+ sleep 5
51
+ if kill -0 $STREMIO_PID 2>/dev/null; then
52
+ echo "Stremio server process is running with PID: $STREMIO_PID"
53
+
54
+ # Try to verify if the server is actually responding
55
+ echo "Checking if server is responding on port 11470..."
56
+ TRIES=0
57
+ SERVER_UP=0
58
 
59
+ while [ $TRIES -lt 5 ]; do
60
+ if nc -z localhost 11470 2>/dev/null; then
61
+ echo "Server is responding on port 11470!"
62
+ SERVER_UP=1
63
+ break
64
+ fi
65
+ echo "Waiting for server to start responding (attempt $((TRIES+1))/5)..."
66
+ TRIES=$((TRIES+1))
67
+ sleep 3
68
+ done
69
+
70
+ if [ $SERVER_UP -eq 1 ]; then
71
+ # Keep container running
72
+ echo "Stremio server is up and running"
73
+ echo "Services started, monitoring processes..."
74
+ wait
75
+ else
76
+ echo "WARNING: Stremio process is running but not responding on port 11470"
77
+ echo "Trying minimal Node.js starter as fallback..."
78
+ kill $STREMIO_PID
79
+ node /app/stremio-minimal.js &
80
+ STREMIO_PID=$!
81
+
82
+ # Check again
83
+ sleep 5
84
+ if kill -0 $STREMIO_PID 2>/dev/null && nc -z localhost 11470 2>/dev/null; then
85
+ echo "Minimal starter is working! Monitoring processes..."
86
+ wait
87
+ else
88
+ echo "ERROR: All Stremio server start attempts failed"
89
+ kill $STREMIO_PID 2>/dev/null
90
+ kill $PROXY_PID 2>/dev/null
91
+
92
+ echo "FALLBACK: Using proxy-only mode"
93
+ exec node /app/proxy-only.js
94
+ fi
95
+ fi
96
  else
97
+ echo "ERROR: Stremio server failed to start"
98
+ echo "Trying minimal Node.js starter as fallback..."
99
+ node /app/stremio-minimal.js &
100
+ STREMIO_PID=$!
101
+
102
+ # Check again
103
+ sleep 5
104
+ if kill -0 $STREMIO_PID 2>/dev/null; then
105
+ echo "Minimal starter is working! Monitoring processes..."
106
+ wait
107
+ else
108
+ echo "ERROR: All Stremio server start attempts failed"
109
+ echo "Terminating proxy..."
110
+ kill $PROXY_PID
111
+
112
+ echo "FALLBACK: Using proxy-only mode"
113
+ exec node /app/proxy-only.js
114
+ fi
115
  fi