File tree Expand file tree Collapse file tree 4 files changed +28
-2
lines changed
Expand file tree Collapse file tree 4 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ WORKDIR /app
2828
2929# Prepare environment
3030RUN mkdir /config \
31- && apk add --no-cache nodejs npm libc6-compat shadow su-exec bash
31+ && apk add --no-cache nodejs npm libc6-compat shadow su-exec bash curl
3232
3333# Copy frontend
3434COPY --from=frontend-build /frontend/node_modules ./frontend/node_modules
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ public static class NWebDavOptionsExtensions
88 public static Func < HttpContext , bool > GetFilter ( this NWebDavOptions options )
99 {
1010 return context => ! context . Request . Path . StartsWithSegments ( "/api" ) &&
11- ! context . Request . Path . StartsWithSegments ( "/view" ) ;
11+ ! context . Request . Path . StartsWithSegments ( "/view" ) &&
12+ ! context . Request . Path . StartsWithSegments ( "/health" ) ;
1213 }
1314}
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ static async Task Main(string[] args)
5151 var builder = WebApplication . CreateBuilder ( args ) ;
5252 builder . Host . UseSerilog ( ) ;
5353 builder . Services . AddControllers ( ) ;
54+ builder . Services . AddHealthChecks ( ) ;
5455 builder . Services
5556 . AddSingleton ( configManager )
5657 . AddSingleton < UsenetStreamingClient > ( )
@@ -85,6 +86,7 @@ static async Task Main(string[] args)
8586
8687 // run
8788 var app = builder . Build ( ) ;
89+ app . MapHealthChecks ( "/health" ) ;
8890 app . UseSerilogRequestLogging ( ) ;
8991 app . UseMiddleware < ExceptionMiddleware > ( ) ;
9092 app . UseAuthentication ( ) ;
Original file line number Diff line number Diff line change @@ -54,6 +54,29 @@ cd /app/backend
5454su-exec appuser ./NzbWebDAV &
5555BACKEND_PID=$!
5656
57+ # Wait for backend health check
58+ echo " Waiting for backend to start."
59+ MAX_RETRIES=30
60+ RETRY_DELAY=1
61+ i=0
62+ while true ; do
63+ echo " Checking backend health: $BACKEND_URL /health ..."
64+ if curl -s -o /dev/null -w " %{http_code}" " $BACKEND_URL /health" | grep -q " ^200$" ; then
65+ echo " Backend is healthy."
66+ break
67+ fi
68+
69+ i=$(( i+ 1 ))
70+ if [ " $i " -ge " $MAX_RETRIES " ]; then
71+ echo " Backend failed health check after $MAX_RETRIES retries. Exiting."
72+ kill $BACKEND_PID
73+ wait $BACKEND_PID
74+ exit 1
75+ fi
76+
77+ sleep " $RETRY_DELAY "
78+ done
79+
5780# Run frontend as appuser in background
5881cd /app/frontend
5982su-exec appuser npm run start &
You can’t perform that action at this time.
0 commit comments