Skip to content

Commit

Permalink
small fixes (#41)
Browse files Browse the repository at this point in the history
* small fixes
  • Loading branch information
tsaridas authored Sep 6, 2024
1 parent ffba3b6 commit c9f5af8
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ghcr-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ jobs:

- name: Run Playwright tests
run: cd tests;npx playwright test || (
docker ps
docker logs $(docker ps | grep stremio | awk '{print $1}')
exit 1
docker ps;
docker logs $(docker ps | grep stremio | awk '{print $1}');
exit 1;
)
- name: Upload image
uses: actions/upload-artifact@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-hub-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:

- name: Run Playwright tests
run: cd tests;npx playwright test || (
docker ps
docker logs $(docker ps | grep stremio | awk '{print $1}')
exit 1
docker ps;
docker logs $(docker ps | grep stremio | awk '{print $1}');
exit 1;
)

- name: Upload image
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-hub-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ jobs:

- name: Run Playwright tests
run: cd tests;npx playwright test || (
docker ps
docker logs $(docker ps | grep stremio | awk '{print $1}')
exit 1
docker ps;
docker logs $(docker ps | grep stremio | awk '{print $1}');
exit 1;
)
- name: Upload image
uses: actions/upload-artifact@v3
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ RUN yarn global add http-server --no-audit --no-optional --mutex network --no-pr
COPY ./stremio-web-service-run.sh ./
COPY ./extract_certificate.js ./
RUN chmod +x stremio-web-service-run.sh
COPY ./restart_if_idle.sh ./
RUN chmod +x restart_if_idle.sh

ENV FFMPEG_BIN=
ENV FFPROBE_BIN=
Expand Down
41 changes: 41 additions & 0 deletions restart_if_idle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

# fix for incomptible df
alias df="df -P"

# URL to check
URL="http://localhost:11470/stats.json"

# Process name
PROCESS_NAME="node server.js"

# Make the HTTP call
response=$(curl -s "$URL")
curl_exit_status=$?

# Check if curl failed (non-zero exit status)
if [ $curl_exit_status -ne 0 ]; then
echo "Curl failed with connection error. Restarting the process..." > /proc/1/fd/1 2>/proc/1/fd/2

# Find the process ID of "node server.js" and kill it
pkill -f "$PROCESS_NAME"

# Restart the process in the background
nohup $PROCESS_NAME > /proc/1/fd/1 2>/proc/1/fd/2 &

echo "Process restarted due to curl connection error." > /proc/1/fd/1 2>/proc/1/fd/2

# Check if the response is an empty JSON object
elif [ "$response" == "{}" ]; then
echo "Empty JSON response detected. Restarting the process..." > /proc/1/fd/1 2>/proc/1/fd/2

# Find the process ID of "node server.js" and kill it
pkill -f "$PROCESS_NAME"

# Restart the process in the background
nohup $PROCESS_NAME > /proc/1/fd/1 2>/proc/1/fd/2 &

echo "Process restarted." > /proc/1/fd/1 2>/proc/1/fd/2
else
echo "Non-empty JSON response. No action needed." > /proc/1/fd/1 2>/proc/1/fd/2
fi
11 changes: 9 additions & 2 deletions stremio-web-service-run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/sh -e
node server.js &
sleep 1
if [ -z "$APP_PATH" ]; then
CONFIG_FOLDER="$HOME"/.stremio-server/
else
CONFIG_FOLDER=$APP_PATH/
fi

# fix for not passed config option
grep -q 'self.proxyStreamsEnabled = false,' server.js || sed -i '/self.allTranscodeProfiles = \[\]/a \ \ \ \ \ \ \ \ self.proxyStreamsEnabled = false,' server.js

# fix for incomptible df
alias df="df -P"

node server.js &
sleep 1

if [ ! -z "$IPADDRESS" ]; then
curl "http://localhost:11470/get-https??authKey=&ipAddress=$IPADDRESS"
CERT=$(node extract_certificate.js "$CONFIG_FOLDER")
Expand Down

0 comments on commit c9f5af8

Please sign in to comment.