c42fe68b362fb43740819be77a067fbd17276515
runCleanup previously had no try/catch around each expired job, so one job's markCleaned/delete failure would abort the whole pass, leaving later expired jobs' files undeleted for that run. Each iteration is now wrapped in a try/catch that logs and continues; the returned count only reflects jobs that actually completed the delete+markCleaned sequence. markDone now guards outputPath/outputMimeType/outputSizeBytes/ conversionDurationSeconds with `?? null`, matching the guard createJob already has on `quality` — Prisma treats `undefined` in a data object as "leave the column alone" rather than binding NULL like the old raw SQL did. Currently unreachable in practice since the worker always passes real values, but keeps the repository defensive and consistent. Added a cleanup.test.js case that monkey-patches prisma.conversionJob.update to reject for one job's cleanedAt update, asserting a later expired job in the same batch still gets cleaned. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
File Converter
Local development
- Copy
.env.exampleto.envand fill in your local MariaDB credentials. - Apply the schema:
mysql -h <host> -u <user> -p <database> < db/schema.sql - Install dependencies:
npm install - Run the API:
npm start - Run the worker (separate terminal):
npm run worker - Run tests:
npm test(requires the same MariaDB reachable via your.envvars, exported into the shell)
Deployment on o2switch
- Upload the project (excluding
node_modules/) via SSH/Git. - Create/adjust
.envon the server with production values (STORAGE_DIRpointing to a writable path under your account, MariaDB credentials from cPanel). npm install --include=dev(never with--ignore-scripts— Puppeteer needs its postinstall step to download Chromium).- Configure the app in cPanel "Setup Node.js App", pointing its entry point at
src/server.js. Passenger manages this process (start/stop/restart). - Start the worker independently of Passenger, over SSH:
./node_modules/.bin/pm2 start ecosystem.config.cjs, thenpm2 save. Trypm2 startupto survive a server reboot; if that's not permitted without root on this account, fall back to a cPanel cron job every 5 minutes that runspm2 resurrect(or checkspm2 listand restarts the app if absent) — validate which option this hosting plan actually allows once connected over SSH. - Add a cPanel cron job to run the cleanup script periodically, e.g. every 15 minutes:
*/15 * * * * cd /home/gaan6043/convert.ombrora.com-node && /home/gaan6043/nodevenv/convert.ombrora.com-node/24/bin/node src/cleanup.js > /dev/null(adjust the path and node binary location to match your actual account — check withwhich nodeover SSH). - On every subsequent deployment: pull changes,
npm install,npm run build(frontend), then restart the Passenger app from cPanel andpm2 restart convert-worker.
Languages
JavaScript
92.9%
CSS
5.8%
HTML
0.9%
Shell
0.4%