Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Wait for backend to start before starting frontend.
nzbdav-dev5eb9988f1322
diff --git a/Dockerfile b/Dockerfileindex 34afd9c1..c33610ec 100644--- a/Dockerfile+++ b/Dockerfile@@ -28,7 +28,7 @@ WORKDIR /app# Prepare environmentRUN mkdir /config \- && apk add --no-cache nodejs npm libc6-compat shadow su-exec bash+ && apk add --no-cache nodejs npm libc6-compat shadow su-exec bash curl# Copy frontendCOPY --from=frontend-build /frontend/node_modules ./frontend/node_modulesdiff --git a/backend/Extensions/NWebDavOptionsExtensions.cs b/backend/Extensions/NWebDavOptionsExtensions.csindex 1fd7bb44..3c4b6c70 100644--- a/backend/Extensions/NWebDavOptionsExtensions.cs+++ b/backend/Extensions/NWebDavOptionsExtensions.cs@@ -8,6 +8,7 @@ public static class NWebDavOptionsExtensionspublic static Func<HttpContext, bool> GetFilter(this NWebDavOptions options){return context => !context.Request.Path.StartsWithSegments("/api") &&- !context.Request.Path.StartsWithSegments("/view");+ !context.Request.Path.StartsWithSegments("/view") &&+ !context.Request.Path.StartsWithSegments("/health");}}\ No newline at end of filediff --git a/backend/Program.cs b/backend/Program.csindex fe3741d9..1d6bc006 100644--- a/backend/Program.cs+++ b/backend/Program.cs@@ -51,6 +51,7 @@ class Programvar builder = WebApplication.CreateBuilder(args);builder.Host.UseSerilog();builder.Services.AddControllers();+ builder.Services.AddHealthChecks();builder.Services.AddSingleton(configManager).AddSingleton<UsenetStreamingClient>()@@ -85,6 +86,7 @@ class Program// runvar app = builder.Build();+ app.MapHealthChecks("/health");app.UseSerilogRequestLogging();app.UseMiddleware<ExceptionMiddleware>();app.UseAuthentication();diff --git a/entrypoint.sh b/entrypoint.shindex 06800c62..3f042b26 100644--- a/entrypoint.sh+++ b/entrypoint.sh@@ -54,6 +54,29 @@ cd /app/backendsu-exec appuser ./NzbWebDAV &BACKEND_PID=$!+# Wait for backend health check+echo "Waiting for backend to start."+MAX_RETRIES=30+RETRY_DELAY=1+i=0+while true; do+ echo "Checking backend health: $BACKEND_URL/health ..."+ if curl -s -o /dev/null -w "%{http_code}" "$BACKEND_URL/health" | grep -q "^200$"; then+ echo "Backend is healthy."+ break+ fi++ i=$((i+1))+ if [ "$i" -ge "$MAX_RETRIES" ]; then+ echo "Backend failed health check after $MAX_RETRIES retries. Exiting."+ kill $BACKEND_PID+ wait $BACKEND_PID+ exit 1+ fi++ sleep "$RETRY_DELAY"+done+# Run frontend as appuser in backgroundcd /app/frontendsu-exec appuser npm run start &