Configure background scheduler in PM2 and optimize cron frequencies#7
Draft
Copilot wants to merge 2 commits into
Draft
Configure background scheduler in PM2 and optimize cron frequencies#7Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…te init script and documentation Co-authored-by: enikqi <10384338+enikqi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix background scheduler and cron jobs system
Configure background scheduler in PM2 and optimize cron frequencies
Nov 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The background scheduler exists but isn't configured to run automatically with PM2, causing cron jobs to fail. Additionally, the auto-processing job runs too frequently (every 30s), causing unnecessary CPU load.
Changes
PM2 Configuration - Added
background-scheduleras second app inecosystem.config.jswith 500M memory limit and dedicated log filesCron Frequency - Reduced auto-processing from every 30 seconds to every 2 minutes in
background-scheduler.jsDatabase Initialization - Added
scripts/init-job-settings.jsto upsert 7 job control settings (auto_processing_enabled, batch sizes, intervals, etc.)Documentation - Added
SCHEDULER_SETUP.mdwith deployment commands, troubleshooting guide, and configuration referenceDeployment
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
checkpoint.prisma.io/usr/local/bin/node /home/REDACTED/work/yapgrid/yapgrid/site/node_modules/prisma/build/child {"product":"prisma","version":"6.17.0","cli_install_type":"local","information":"","local_timestamp":"2025-11-04T22:16:06Z","project_hash":"035950a5","cli_path":"/home/REDACTED/work/yapgrid/yapgrid/site/node_modules/.bin/prisma","cli_path_hash":"0fcc53eb","endpoint":"REDACTED","disable":false,"arch":"x64","os":"linux","node_version":"v20.19.5","ci":true,"ci_name":"GitHub Actions","command":"generate --postinstall \"UNABLE_TO_FIND_POSTINSTALL_TRIGGER__ENVAR_MISSING\"","schema_providers":["sqlite"],"schema_preview_features":[],"schema_generators_providers":["prisma-client-js"],"cache_file":"/home/REDACTED/.cache/checkpoint-nodejs/prisma-0fcc53eb","cache_duration":43200000,"remind_duration":172800000,"force":false,"timeout":5000,"unref":true,"child_path":"/home/REDACTED/work/yapgrid/yapgrid/site/node_modules/prisma/build/child","client_event_id":"","previous_client_event_id":"","check_if_update_available":true}(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fix Background Scheduler & Cron Jobs System
Problem Overview
The background scheduler exists but is not properly configured in PM2, causing jobs to not run automatically. Additionally, cron job frequencies need optimization and database settings need to be properly initialized.
Required Changes
1. Add Background Scheduler to PM2 Configuration
File:
site/ecosystem.config.jsCurrently only has
yapgrid-nextjs. Need to addbackground-scheduleras a second app.Change from:
To:
2. Optimize Cron Job Frequency
File:
site/background-scheduler.jsLine 9 - Change auto-processing frequency from every 30 seconds to every 2 minutes:
Change from:
To:
Line 214 - Update console log to reflect new timing:
Change from:
To:
3. Add Database Settings Initialization Script
File:
site/scripts/init-job-settings.js(CREATE NEW FILE)Create a new script to initialize database settings for job control: