-
Notifications
You must be signed in to change notification settings - Fork 68
feat: add cron job for keep-alive ping to external service #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for paisable ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a keep-alive mechanism to prevent Render free tier from idling by adding a cron job that pings the external service every 10 minutes.
- Adds node-cron and axios dependencies for scheduling and HTTP requests
- Implements a cron job that runs every 10 minutes to send keep-alive pings
- Includes basic error handling with console logging for ping status
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
backend/server.js
Outdated
try { | ||
await axios.get("https://paisable.onrender.com"); |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded URL should be moved to an environment variable to improve maintainability and allow different URLs for different environments.
try { | |
await axios.get("https://paisable.onrender.com"); | |
const keepAliveUrl = process.env.KEEP_ALIVE_URL; | |
if (!keepAliveUrl) { | |
console.error("KEEP_ALIVE_URL environment variable is not set. Skipping keep-alive ping."); | |
return; | |
} | |
try { | |
await axios.get(keepAliveUrl); |
Copilot uses AI. Check for mistakes.
cron.schedule("*/10 * * * *", async () => { | ||
try { | ||
await axios.get("https://paisable.onrender.com"); | ||
console.log("Keep-alive ping sent ✅"); | ||
} catch (error) { | ||
console.error("Keep-alive failed ❌", error.message); | ||
} | ||
}); |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a timeout to the axios request to prevent the cron job from hanging indefinitely if the external service is unresponsive.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Shitanshukumar607 Thank you for opening the PR.
Please remove the backend API URL from the code and put it in the .env file and I see there are manual changes to the lockfile (package-lock.json) too, you have removed the "dev": true field from some packages. It might cause the lockfile to break. Please revert those changes so that the lockfile is consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- backend/package-lock.json: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@archa8 i have put backend API URL in the env and about the changes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@archa8 Thanks for merging the PR, can you also add the hacktober fest labels? Thanks |
@archa8 please add hacktober fest labels |
Hey @Shitanshukumar607, Hacktoberfest will automatically count this as your contribution, it doesn't need separate labels. |
Description
Implemented a simple keep-alive solution using node-cron to send requests every 10 minutes, preventing Render free tier from idling and improving user experience by reducing cold start delays
Related Issue
Fixes #51
Motivation and Context
Types of Changes
How Has This Been Tested?
Screenshots (if applicable):
Checklist