Add redis to dockerfile.
This commit is contained in:
@@ -18,6 +18,13 @@ COPY . .
|
|||||||
RUN apt -y update
|
RUN apt -y update
|
||||||
RUN apt install -y wget
|
RUN apt install -y wget
|
||||||
|
|
||||||
|
RUN apt install -y lsb-release curl gpg
|
||||||
|
RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
|
||||||
|
RUN chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
|
||||||
|
RUN echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install -y redis
|
||||||
|
|
||||||
# PNG ,JPG ,Tiff & WebP support
|
# PNG ,JPG ,Tiff & WebP support
|
||||||
# Consider adding more support with testing https://gist.github.com/hurricup/e14ae5bc47705fca6b1680e7a1fb6580
|
# Consider adding more support with testing https://gist.github.com/hurricup/e14ae5bc47705fca6b1680e7a1fb6580
|
||||||
RUN apt install -y libjpeg-dev
|
RUN apt install -y libjpeg-dev
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export async function jobsUploadMedia(req: Request, res: Response) {
|
|||||||
|
|
||||||
//Check if there's a heic in the file set. If so, modify the file set.
|
//Check if there's a heic in the file set. If so, modify the file set.
|
||||||
await ConvertHeicFiles(req.files as Express.Multer.File[]);
|
await ConvertHeicFiles(req.files as Express.Multer.File[]);
|
||||||
return;
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Creating thumbnails for newly uploaded media",
|
"Creating thumbnails for newly uploaded media",
|
||||||
(req.files as Express.Multer.File[]).map((f) => f.filename)
|
(req.files as Express.Multer.File[]).map((f) => f.filename)
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ export default async function GenerateThumbnail(
|
|||||||
await simpleThumb(file, thumbPath, "250x?", {
|
await simpleThumb(file, thumbPath, "250x?", {
|
||||||
// path: ffmpeg,
|
// path: ffmpeg,
|
||||||
});
|
});
|
||||||
|
} else if (type?.mime === "image/heic" || type?.mime === "image/heif") {
|
||||||
|
await GeneratePdfThumbnail(file, thumbPath);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Thumbnail being created for : " + thumbPath);
|
logger.debug("Thumbnail being created for : " + thumbPath);
|
||||||
//Ignoring typescript as the interface is lacking a parameter.
|
//Ignoring typescript as the interface is lacking a parameter.
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { FolderPaths } from "./serverInit.js";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const HeicQueue = new Queue("HEIC Queue", { connection: { host: "localhost", port: 6379 , } });
|
const HeicQueue = new Queue("HEIC Queue", { connection: { host: "localhost", port: 6379 } });
|
||||||
|
|
||||||
dotenv.config({
|
dotenv.config({
|
||||||
path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`)
|
path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`)
|
||||||
@@ -23,8 +23,12 @@ const imageMagick = gm.subClass({ imageMagick: true });
|
|||||||
export async function ConvertHeicFiles(files: Express.Multer.File[]) {
|
export async function ConvertHeicFiles(files: Express.Multer.File[]) {
|
||||||
const validFiles = await filterValidHeicFiles(files);
|
const validFiles = await filterValidHeicFiles(files);
|
||||||
|
|
||||||
const jobs = await HeicQueue.addBulk(validFiles.map(file => ({name: file.filename, data: {convertedFileName:generateUniqueHeicFilename(file) , file} })))
|
const jobs = await HeicQueue.addBulk(
|
||||||
logger.log("debug", `The Jobs Object ${(JSON.stringify(jobs,null,2))}`)
|
validFiles.map((file) => ({
|
||||||
|
name: file.filename,
|
||||||
|
data: { convertedFileName: generateUniqueHeicFilename(file), file }
|
||||||
|
}))
|
||||||
|
);
|
||||||
// await Promise.all(
|
// await Promise.all(
|
||||||
// validFiles.map(async (file) => {
|
// validFiles.map(async (file) => {
|
||||||
// const convertedFileName = generateUniqueHeicFilename(file);
|
// const convertedFileName = generateUniqueHeicFilename(file);
|
||||||
@@ -96,43 +100,46 @@ const HeicWorker = new Worker(
|
|||||||
file.path = `${file.destination}/${convertedFileName}`;
|
file.path = `${file.destination}/${convertedFileName}`;
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log("error", `QUEUE ERROR: Error converting ${file.filename} image to JPEG from HEIC. ${JSON.stringify(error)}`);
|
logger.log(
|
||||||
|
"error",
|
||||||
|
`QUEUE ERROR: Error converting ${file.filename} image to JPEG from HEIC. ${JSON.stringify(error)}`
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
connection: { host: "localhost", port: 6379 },
|
connection: { host: "localhost", port: 6379 }
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
HeicQueue.on('waiting', job => {
|
HeicQueue.on("waiting", (job) => {
|
||||||
logger.log("debug", `Job is waiting in queue! ${job.data.convertedFileName}`);
|
logger.log("debug", `[BULLMQ] Job is waiting in queue! ${job.data.convertedFileName}`);
|
||||||
})
|
});
|
||||||
HeicQueue.on('error', error => {
|
HeicQueue.on("error", (error) => {
|
||||||
logger.log("error", `Queue Error! ${error}`);
|
logger.log("error", `[BULLMQ] Queue Error! ${error}`);
|
||||||
})
|
});
|
||||||
|
|
||||||
HeicWorker.on("ready", () => {
|
HeicWorker.on("ready", () => {
|
||||||
logger.log('debug',`Worker Ready`);
|
logger.log("debug", `[BULLMQ] Worker Ready`);
|
||||||
});
|
});
|
||||||
HeicWorker.on("active", (job, prev) => {
|
HeicWorker.on("active", (job, prev) => {
|
||||||
logger.log('debug',`Job ${job.id} is now active; previous status was ${prev}`);
|
logger.log("debug", `[BULLMQ] Job ${job.id} is now active; previous status was ${prev}`);
|
||||||
});
|
});
|
||||||
HeicWorker.on("completed", (jobId, returnvalue) => {
|
HeicWorker.on("completed", (jobId, returnvalue) => {
|
||||||
logger.log('debug',`${jobId.id} has completed and returned ${returnvalue}`);
|
logger.log("debug", `[BULLMQ] ${jobId.id} has completed and returned ${returnvalue}`);
|
||||||
});
|
});
|
||||||
HeicWorker.on("failed", (jobId, failedReason) => {
|
HeicWorker.on("failed", (jobId, failedReason) => {
|
||||||
logger.log('error',`${jobId} has failed with reason ${failedReason}`);
|
logger.log("error", `[BULLMQ] ${jobId} has failed with reason ${failedReason}`);
|
||||||
|
});
|
||||||
|
HeicWorker.on("error", (error) => {
|
||||||
|
logger.log("error", `[BULLMQ] There was a queue error! ${error}`);
|
||||||
|
});
|
||||||
|
HeicWorker.on("stalled", (error) => {
|
||||||
|
logger.log("error", `[BULLMQ] There was a worker stall! ${error}`);
|
||||||
|
});
|
||||||
|
HeicWorker.on("ioredis:close", () => {
|
||||||
|
logger.log("error", `[BULLMQ] Redis connection closed!`);
|
||||||
});
|
});
|
||||||
HeicWorker.on('error', error => {
|
|
||||||
logger.log('error', `There was a queue error! ${error}`)
|
|
||||||
})
|
|
||||||
HeicWorker.on('stalled', error => {
|
|
||||||
logger.log('error', `There was a worker stall! ${error}`)
|
|
||||||
})
|
|
||||||
HeicWorker.on('ioredis:close', () => {
|
|
||||||
logger.log('error', `Redis connection closed!`)
|
|
||||||
})
|
|
||||||
|
|
||||||
// const queueEvents = new QueueEvents( "HEIC Queue");
|
// const queueEvents = new QueueEvents( "HEIC Queue");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user