977dac35d91ba7a2edf88693bb9a8b7cbb8b8896
File Converter
Local development
- Copy
.env.exampleto.envand fill in your local MariaDB credentials. - Install dependencies:
npm install - Export those same
DB_HOST/DB_USER/DB_PASSWORD/DB_NAMEvalues from.envinto your shell, then apply the schema with Prisma Migrate (creates theconversion_jobstable fresh, since a new local database starts empty):DATABASE_URL=$(node scripts/printDatabaseUrl.js) npx prisma migrate deploy - 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). - ONE-TIME, before ever running
prisma migrate deployon this server: the o2switch database already has theconversion_jobstable (created by hand, before this project used Prisma), but no_prisma_migrationstracking table. Runningmigrate deployfirst would try toCREATE TABLE conversion_jobsagain and fail with a "table already exists" MySQL error, leaving Prisma's migration history stuck and needing manual recovery. Avoid that by baselining the existing table once, ever, on this server, before step 8'smigrate deployruns for the first time:DATABASE_URL=$(node scripts/printDatabaseUrl.js) npx prisma migrate resolve --applied 0_initDo not repeat this step on later deployments — after this one-time run,migrate deploy(step 8) is the correct command going forward. - On every subsequent deployment: pull changes,
npm run deploy
Languages
JavaScript
92.9%
CSS
5.8%
HTML
0.9%
Shell
0.4%