Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stability of dev environment #60

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ WORKDIR /app
RUN cargo install cargo-watch
ENV ROCKET_ADDRESS=0.0.0.0
EXPOSE 8000
# We reduce the pool_size because of this: https://github.com/rwf2/Rocket/issues/1931#issuecomment-955945953
CMD cargo build && cd api && DB_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" ROCKET_DATABASES="{sea_orm={url=$DB_URL, pool_size=1}}" cargo watch -x run
CMD cargo build && cd api && DB_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}" ROCKET_DATABASES="{sea_orm={url=$DB_URL, pool_size=15}}" cargo watch -s "while true; do cargo run; done"
3 changes: 0 additions & 3 deletions api/api/src/services/package.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::borrow::Borrow;

use crate::dto::{
artist::ArtistResponse,
package::{PackageFilter, PackageResponse, PackageResponseWithRelations, PackageSort},
Expand Down Expand Up @@ -106,7 +104,6 @@ where
.await?
.map_or(Err(DbErr::RecordNotFound("Package".to_string())), |r| Ok(r))?;

dbg!(package.artist_name.borrow());
Ok(PackageResponseWithRelations {
package: package.into(),
poster: poster.map(|x| x.into()),
Expand Down
7 changes: 7 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ services:
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
healthcheck:
test: curl --fail http://localhost:8000/ || exit 1
interval: 10s
Expand All @@ -48,6 +50,11 @@ services:
environment:
- RABBITMQ_DEFAULT_USER=${RABBIT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBIT_PASS}
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 5s
timeout: 5s
retries: 10
matcher:
build:
context: ./matcher
Expand Down
14 changes: 6 additions & 8 deletions scanner/pkg/actions/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ func RegisterFile(path string, c *config.Config) error {
glg.Failf(err.Error())
return err
}
go func() {
for i, chapterId := range res.ChaptersId {
thumbnailBytes, err := pkg.GetFrame(path, int64(dto.Chapters[i].StartTimestamp)+int64(dto.Chapters[i].EndTimestamp-dto.Chapters[i].StartTimestamp)/2)
api.SaveChapterThumbnail(chapterId, thumbnailBytes, *c)
if err != nil {
glg.Fail(err)
}
for i, chapterId := range res.ChaptersId {
thumbnailBytes, err := pkg.GetFrame(path, int64(dto.Chapters[i].StartTimestamp)+int64(dto.Chapters[i].EndTimestamp-dto.Chapters[i].StartTimestamp)/2)
api.SaveChapterThumbnail(chapterId, thumbnailBytes, *c)
if err != nil {
glg.Fail(err)
}
}()
}
} else if parsedPath.Extra != nil {
dto, err := buildExtraDto(path, parsedPath.Extra, mediainfo)

Expand Down
6 changes: 1 addition & 5 deletions scanner/pkg/thumbnail.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ package pkg
import (
"bytes"
"fmt"
// "fmt"
"io"
"os"

// "time"

"github.com/u2takey/ffmpeg-go"
)
Expand All @@ -18,6 +14,6 @@ func GetFrame(filepath string, timestamp int64) (io.Reader, error) {
err := ffmpeg_go.Input(filepath, ffmpeg_go.KwArgs{"ss": formattedDuration}).
Filter("select", ffmpeg_go.Args{"gte(n,1)"}).
Output("pipe:", ffmpeg_go.KwArgs{"vframes": 1, "format": "image2", "vcodec": "mjpeg"}).
WithOutput(buf, os.Stdout).Run()
WithOutput(buf).Run()
return buf, err
}
Loading