diff --git a/activemq/Dockerfile b/activemq/Dockerfile index f3b91550..473104ba 100644 --- a/activemq/Dockerfile +++ b/activemq/Dockerfile @@ -1,4 +1,6 @@ FROM symptoma/activemq:latest +COPY activemq.xml /opt/activemq/conf/activemq.xml + CMD ["/bin/sh", "-c", "bin/activemq console -Djetty.host=0.0.0.0"] \ No newline at end of file diff --git a/activemq/activemq.xml b/activemq/activemq.xml new file mode 100644 index 00000000..6c1e1416 --- /dev/null +++ b/activemq/activemq.xml @@ -0,0 +1,133 @@ + + + + + + + + file:${activemq.conf}/credentials.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scheduler/Dockerfile b/scheduler/Dockerfile index bec56450..d91ee03a 100755 --- a/scheduler/Dockerfile +++ b/scheduler/Dockerfile @@ -12,7 +12,7 @@ RUN cd ffmpeg-git-*-amd64-static && cp ffmpeg /usr/local/bin/ffmpeg # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -FROM golang:1.16-alpine as builder +FROM golang:1.17-alpine as builder LABEL org.opencontainers.image.source=https://github.com/horahoradev/horahora WORKDIR /horahora/scheduler @@ -35,7 +35,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build go build -o /scheduler.bin FROM python:3.9-alpine AS runtime LABEL org.opencontainers.image.source=https://github.com/horahoradev/horahora -RUN apk add --update --no-cache zlib-dev musl-dev libc-dev libffi-dev gcc g++ git pwgen && git clone -b STOMP_progress --depth 5 https://github.com/horahoradev/yt-dlp.git yt-dlp +RUN apk add --update --no-cache zlib-dev musl-dev libc-dev libffi-dev gcc g++ git pwgen && git clone -b STOMP_progress --depth 2 https://github.com/horahoradev/yt-dlp.git yt-dlp # download yt-dlp and prepare it for usage WORKDIR /yt-dlp diff --git a/scheduler/internal/models/video_dl_request.go b/scheduler/internal/models/video_dl_request.go index 289e6951..70f732a1 100644 --- a/scheduler/internal/models/video_dl_request.go +++ b/scheduler/internal/models/video_dl_request.go @@ -103,7 +103,7 @@ func (v *VideoDLRequest) PublishVideoInprogress(dlStatus int, action string) err return err } - err = v.Rabbitmq.Send("/topic/state", "text/json", payload, stomp.SendOpt.Receipt) + err = v.Rabbitmq.Send("/topic/state", "text/json", payload, stomp.SendOpt.Receipt, stomp.SendOpt.Header("persistent", "false"), stomp.SendOpt.Header("expires", fmt.Sprintf("%d", time.Now().Local().UnixMilli()+30000))) if err != nil { return fmt.Errorf("Publish: %v", err) } diff --git a/webapp/src/ArchivalPage.js b/webapp/src/ArchivalPage.js index be988729..4ee3229b 100644 --- a/webapp/src/ArchivalPage.js +++ b/webapp/src/ArchivalPage.js @@ -115,7 +115,6 @@ function ArchivalPage() { conn != null && conn.subscribe(`/topic/state`, function(message) { mutex.lock(); let body = JSON.parse(message.body); - message.ack(); if (body.Type == "deletion") { console.log(`Got delete ${body.Video.VideoID}`); setVideoInProgressDataset(videosInProg => { @@ -129,8 +128,7 @@ function ArchivalPage() { console.log(`Got insert ${body.Video.VideoID}`); setVideoInProgressDataset(videosInProg => { - if (videosInProg == null) { return videosInProg; } - let dataset = JSON.parse(JSON.stringify(videosInProg)) + let dataset = videosInProg != null ? JSON.parse(JSON.stringify(videosInProg)) : []; // // Does it already exist? If not, subscribe let videosID = dataset.filter((item)=>item.VideoID == body.Video.VideoID); @@ -139,7 +137,7 @@ function ArchivalPage() { } // Needed for upsert, filter it out if it's in there with a different dlStatus - dataset = dataset.filter((item)=>item.VideoID != body.Video.VideoID || body.Video.DlStatus != item.DlStatus); + dataset = dataset.filter((item)=>item.VideoID != body.Video.VideoID || body.Video.DlStatus == item.DlStatus); body.Video.progress = 0; // If it's downloading, it goes at the beginning if (body.Video.DlStatus == "Downloading") { @@ -152,9 +150,10 @@ function ArchivalPage() { return dataset; }); } + message.ack(); + mutex.unlock(); - }, {'prefetch-count': 100, 'ack': 'client-individual', 'id': String(Math.random() * 1000)}); - return conn; + }, {'prefetch-count': 1, 'ack': 'client-individual', 'id': String(Math.random() * 1000)}); }, [conn]); diff --git a/webapp/src/VideoPage.js b/webapp/src/VideoPage.js index 1b470262..10d1ca09 100644 --- a/webapp/src/VideoPage.js +++ b/webapp/src/VideoPage.js @@ -110,7 +110,7 @@ function VideoAdminControls(props) { } function VideoView(props) { - let { data, id, setRating, next_video, videoComments, refreshComments} = props; + let { rating, data, id, setRating, next_video, videoComments, refreshComments} = props; // video_id, content (content of comment), and parent (parent comment id if a reply) let formik = useFormik({ @@ -131,12 +131,12 @@ function VideoView(props) { await refreshComments(); }; - function rate(rating) { + async function rate(rating) { if (id == 0) { // TODO: throw return; } - API.postRating(id, rating); + await API.postRating(id, rating); setRating(rating); } @@ -150,7 +150,7 @@ function VideoView(props) { {data.Views} Views -
+

{data.UploadDate} @@ -269,8 +269,8 @@ function VideoPage() { let fetchData = async () => { let data = await API.getVideo(id); + if (data) setRating(data.Rating); if (!ignore) setPageData(data); - if (!ignore) setRating(data.Rating); let userData = await API.getUserdata(); if (!ignore) setUserData(userData); @@ -283,7 +283,7 @@ function VideoPage() { return () => { ignore = true; }; - }, [id, rating]); + }, [id]); if (pageData == null) return null; @@ -292,7 +292,7 @@ function VideoPage() {
- +