Add Healthcheck; Search missing immediately (#36)

This commit is contained in:
Mukhtar Akere
2025-01-31 23:45:30 +01:00
committed by GitHub
parent 92504cc8e0
commit 64995d0bf3
4 changed files with 44 additions and 9 deletions

View File

@@ -19,16 +19,27 @@ ADD . .
# Build
RUN CGO_ENABLED=0 GOOS=$(echo $TARGETPLATFORM | cut -d '/' -f1) GOARCH=$(echo $TARGETPLATFORM | cut -d '/' -f2) go build -ldflags="-X github.com/sirrobot01/debrid-blackhole/pkg/version.Version=${VERSION} -X github.com/sirrobot01/debrid-blackhole/pkg/version.Channel=${CHANNEL}" -o /blackhole
RUN CGO_ENABLED=0 GOOS=$(echo $TARGETPLATFORM | cut -d '/' -f1) GOARCH=$(echo $TARGETPLATFORM | cut -d '/' -f2) go build -o /healthcheck cmd/healthcheck/main.go
FROM alpine as logsetup
RUN mkdir -p /logs && \
touch /logs/decypharr.log && \
chmod -R 755 /logs && \
chmod 666 /logs/decypharr.log
ARG PUID=1000
ARG PGID=1000
RUN addgroup -g $PGID appuser && \
adduser -D -u $PUID -G appuser appuser && \
mkdir -p /logs && \
chown -R appuser:appuser /logs && \
mkdir -p /app && \
chown appuser:appuser /app
FROM gcr.io/distroless/static-debian12:latest
COPY --from=builder /blackhole /blackhole
COPY --from=builder /healthcheck /healthcheck
COPY --from=builder /app/README.md /README.md
COPY --from=logsetup /etc/passwd /etc/passwd
COPY --from=logsetup /etc/group /etc/group
COPY --from=logsetup /logs /logs
COPY --from=logsetup /app /app
ENV LOG_PATH=/logs
@@ -36,5 +47,9 @@ EXPOSE 8181 8282
VOLUME ["/app"]
USER appuser
HEALTHCHECK CMD ["/healthcheck"]
# Run
CMD ["/blackhole", "--config", "/app/config.json"]

22
cmd/healthcheck/main.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"cmp"
"net/http"
"os"
)
func main() {
port := cmp.Or(os.Getenv("QBIT_PORT"), "8282")
resp, err := http.Get("http://localhost:" + port + "/api/v2/app/version")
if err != nil {
os.Exit(1)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
os.Exit(1)
}
os.Exit(0)
}

View File

@@ -72,10 +72,6 @@ func (a *Arr) Repair(tmdbId string) error {
getLogger().Info().Msgf("Found %d %s broken media files", len(brokenMedia), a.Type)
// Automatic search for missing files
for _, m := range brokenMedia {
getLogger().Debug().Msgf("Searching missing for %s", m.Title)
a.SearchMissing(m.Id)
}
getLogger().Info().Msgf("Repair completed for %s", a.Name)
return nil
}
@@ -90,6 +86,7 @@ func (a *Arr) processMedia(media []Content) []Content {
continue
}
if a.checkMediaFiles(m) {
a.SearchMissing(m.Id)
brokenMedia = append(brokenMedia, m)
}
}
@@ -118,6 +115,7 @@ func (a *Arr) processMedia(media []Content) []Content {
continue
}
if a.checkMediaFilesParallel(m) {
a.SearchMissing(m.Id)
results <- m
}
}

View File

@@ -26,7 +26,7 @@ type QBit struct {
func NewQBit(config *common.Config, deb *debrid.DebridService, logger zerolog.Logger, arrs *arr.Storage) *QBit {
cfg := config.QBitTorrent
port := cmp.Or(cfg.Port, os.Getenv("QBIT_PORT"), "8182")
port := cmp.Or(cfg.Port, os.Getenv("QBIT_PORT"), "8282")
refreshInterval := cmp.Or(cfg.RefreshInterval, 10)
return &QBit{
Username: cfg.Username,