malt666 commited on
Commit
b29a312
·
verified ·
1 Parent(s): f3278b8

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -16
Dockerfile CHANGED
@@ -227,28 +227,42 @@ ENTRYPOINT ["tini", "--", "sh", "-c", " \
227
  fi; \
228
  # --- END: Dynamically Install Extensions at Runtime --- \
229
 
230
- echo 'Starting SillyTavern server directly...'; \
231
-
232
  # --- BEGIN: Create and run keep-alive script --- \
233
- echo '--- Creating keep-alive script love.sh ---'; \
234
- cat << 'EOF' > ./love.sh && \
235
- #!/bin/sh
236
- # Keep SillyTavern alive for Hugging Face Spaces
 
 
 
 
 
 
237
  while true; do
238
- echo \"Sending keep-alive request to SillyTavern...\"
239
- # Use -s for silent, -o /dev/null to discard output
240
- curl -s http://localhost:8000/ > /dev/null
241
- sleep 1800 # Sleep for 30 minutes (1800 seconds)
 
 
 
 
 
 
 
242
  done
243
- EOF
244
- echo '--- Making love.sh executable ---'; \
 
 
245
  chmod +x ./love.sh && \
246
- echo '--- Running love.sh in background ---'; \
247
- # Run in background and redirect stdout/stderr to a log file \
248
- ./love.sh > ./love.log 2>&1 & \
249
- echo '--- Keep-alive script started in background ---'; \
250
  # --- END: Create and run keep-alive script --- \
251
 
 
 
252
  # --- BEGIN: Cleanup before start --- \
253
  # Remove .gitignore
254
  echo 'Attempting final removal of .gitignore...' && \
 
227
  fi; \
228
  # --- END: Dynamically Install Extensions at Runtime --- \
229
 
 
 
230
  # --- BEGIN: Create and run keep-alive script --- \
231
+ echo '--- Creating and running keep-alive script (love.sh) ---'; \
232
+ cat << 'EOF_LOVE_SCRIPT' > ./love.sh \
233
+ #!/bin/bash
234
+ # Keep SillyTavern alive for Hugging Face Spaces sleep prevention
235
+
236
+ echo "Starting SillyTavern keep-alive script..."
237
+
238
+ # Give the main server a moment to start
239
+ sleep 10
240
+
241
  while true; do
242
+ echo "Sending keep-alive request to http://localhost:8000/..."
243
+ # Use --silent and --output /dev/null to avoid spamming logs with curl output
244
+ curl --silent --output /dev/null http://localhost:8000/
245
+ if [ $? -eq 0 ]; then
246
+ echo "Keep-alive request successful."
247
+ else
248
+ # Only print warning on failure
249
+ echo "Warning: Keep-alive request failed. SillyTavern might not be running or accessible."
250
+ fi
251
+ # Wait for 30 minutes (1800 seconds)
252
+ sleep 1800
253
  done
254
+
255
+ echo "SillyTavern keep-alive script finished." # Should not be reached
256
+ EOF_LOVE_SCRIPT
257
+ \
258
  chmod +x ./love.sh && \
259
+ echo 'Running love.sh in background...' && \
260
+ ./love.sh & \
261
+ echo '--- Keep-alive script started in background. ---'; \
 
262
  # --- END: Create and run keep-alive script --- \
263
 
264
+ echo 'Starting SillyTavern server directly...'; \
265
+
266
  # --- BEGIN: Cleanup before start --- \
267
  # Remove .gitignore
268
  echo 'Attempting final removal of .gitignore...' && \