Skip to content

Commit

Permalink
media-isolated: fix local infinite loop bug, fix logging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ar committed Aug 15, 2024
1 parent 8cb41ba commit d7836f7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion desci-media-isolated/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ COPY . .
EXPOSE 9777

ENTRYPOINT ["/usr/src/app/scripts/containerInitDev.sh"]
CMD ["dumb-init", "npx", "tsx","watch", "--env-file=.env", "--inspect=0.0.0.0:9777", "src/index.ts"]
CMD ["dumb-init", "npx", "tsx","watch", "--clear-screen=false", "--env-file=.env", "--inspect=0.0.0.0:9777", "src/index.ts"]

FROM base as production
# Cache mounts for faster builds, prod env for better express perf
Expand Down
2 changes: 2 additions & 0 deletions desci-media-isolated/scripts/containerInitDev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

# Check if .env file does not exist and auto generate it from .example.env
if [ ! -f /usr/src/app/.env ]; then
cp /usr/src/app/.env.example /usr/src/app/.env
Expand Down
2 changes: 2 additions & 0 deletions desci-media-isolated/scripts/containerInitProd.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

# Ensure temp directories exist
mkdir -p /usr/src/app/.temp/files /usr/src/app/.temp/thumbnails /usr/src/app/.temp/files/pdf /usr/src/app/.temp/pdf

Expand Down
2 changes: 0 additions & 2 deletions desci-media-isolated/src/controllers/pdf/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const generatePreview = async (
if (!pages) throw new BadRequestError('Missing pages number array in request body');

try {
// debugger;
console.log('start preview', cid);
const previewPaths = await PdfManipulationService.generatePdfPreviews(cid, `${cid}.pdf`, pages, height);
console.log('done preview', cid);
Expand All @@ -51,7 +50,6 @@ export const generatePreview = async (
}
}

console.log({ done: previewBuffers });
res.setHeader('Content-Type', 'application/json');

res.on('finish', async () => {
Expand Down
9 changes: 2 additions & 7 deletions desci-media-isolated/src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ const devTransport = {

console.log('[Media Isolated - DIR NAME]::', __dirname, __filename, logLevel);

const fileTransport = {
target: 'pino/file',
options: { destination: `${__dirname}/../log/server.log` },
level: 'trace',
};

export const logger = pino({
level: logLevel,
serializers: {
Expand Down Expand Up @@ -98,7 +92,7 @@ export const logger = pino({
process.env.NODE_ENV === 'production'
? undefined
: {
targets: [devTransport, fileTransport],
targets: [devTransport],
},
redact: {
paths: [
Expand Down Expand Up @@ -135,4 +129,5 @@ function omitBuffer(array: any[]) {

process.on('uncaughtException', (err) => {
logger.fatal(err, 'uncaught exception');
process.exit(1);
});
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ services:
ports:
- "9777:9777" # debugger
- "7771:7771" # Uncomment if you want to test the media server from the host machine
environment:
DPID_RESOLVER_URL: http://host.docker.internal:5460

grobid:
image: lfoppiano/grobid:0.8.0
Expand Down

0 comments on commit d7836f7

Please sign in to comment.