y59 commited on
Commit
bfe9c22
·
verified ·
1 Parent(s): 0323105

Update startup.sh

Browse files
Files changed (1) hide show
  1. startup.sh +28 -45
startup.sh CHANGED
@@ -1,57 +1,40 @@
1
  #!/bin/sh
2
- set -e
3
 
4
- echo "===== Starting Stremio Server for Hugging Face Spaces ====="
5
- echo "Current time: $(date)"
6
- echo "Checking environment..."
 
 
 
 
 
 
7
  echo "Node version: $(node -v)"
8
  echo "NPM version: $(npm -v)"
 
 
9
 
10
- # Set up stremio data directory in /tmp which should be writable
11
- export STREMIO_USER_DATA_DIR="/tmp/.stremio-server"
12
- export HOME="/tmp"
13
- mkdir -p $STREMIO_USER_DATA_DIR
14
- echo "Initialized Stremio directories in $STREMIO_USER_DATA_DIR"
15
 
16
- # Print current directories for debugging
17
- echo "Directory permissions:"
18
- ls -la /tmp
19
- echo "Current user: $(whoami)"
20
- echo "Current user ID: $(id)"
21
 
22
- # Start Stremio server in background with increased logging
 
 
 
23
  echo "Starting Stremio server on port 11470..."
24
- export STREMIO_LOGGING=1
25
- export NO_CORS=1
26
  /app/stremio-web-service-run.sh &
27
  STREMIO_PID=$!
28
  echo "Stremio server started with PID: $STREMIO_PID"
29
 
30
- # Give a longer time for initialization (30 seconds instead of 10)
31
- echo "Waiting for Stremio server to initialize (30s)..."
32
- for i in $(seq 1 6); do
33
- echo "Initialization progress: $i/6"
34
- sleep 5
35
-
36
- # Check if process is still running during wait
37
- if ! kill -0 $STREMIO_PID 2>/dev/null; then
38
- echo "ERROR: Stremio server process died during initialization"
39
- # Continue anyway, the proxy will handle the error
40
- break
41
- fi
42
- done
43
-
44
- # Check if Stremio process is still running
45
- if kill -0 $STREMIO_PID 2>/dev/null; then
46
- echo "Stremio server is running with PID: $STREMIO_PID"
47
- else
48
- echo "WARNING: Stremio server process is not running. Starting proxy anyway."
49
- fi
50
-
51
- # List running processes for debugging
52
- echo "Current running processes:"
53
- ps aux | grep -v grep | grep -E 'node|stremio'
54
-
55
- # Start proxy in foreground
56
- echo "Starting proxy to forward port 7860 to 11470..."
57
- exec node /app/proxy.js
 
1
  #!/bin/sh
 
2
 
3
+ # Print startup information
4
+ echo "===== Stremio for Hugging Face Spaces ====="
5
+ echo "Starting at: $(date)"
6
+
7
+ # Create data directory in /tmp (which should be writable)
8
+ mkdir -p /tmp/.stremio-server
9
+ echo "Created data directory in /tmp/.stremio-server"
10
+
11
+ # Print environment info for debugging
12
  echo "Node version: $(node -v)"
13
  echo "NPM version: $(npm -v)"
14
+ echo "User: $(whoami)"
15
+ echo "Current working directory: $(pwd)"
16
 
17
+ # Set environment variables
18
+ export HOME=/tmp
19
+ export STREMIO_USER_DATA_DIR=/tmp/.stremio-server
20
+ export NO_CORS=1
21
+ export CASTING_DISABLED=1
22
 
23
+ # Start proxy first to ensure Hugging Face health checks work
24
+ echo "Starting proxy server on port 7860..."
25
+ node /app/proxy.js &
26
+ PROXY_PID=$!
27
+ echo "Proxy started with PID: $PROXY_PID"
28
 
29
+ # Slight delay before starting Stremio
30
+ sleep 2
31
+
32
+ # Start Stremio server
33
  echo "Starting Stremio server on port 11470..."
 
 
34
  /app/stremio-web-service-run.sh &
35
  STREMIO_PID=$!
36
  echo "Stremio server started with PID: $STREMIO_PID"
37
 
38
+ # Keep container running
39
+ echo "Services started, monitoring processes..."
40
+ wait