Spaces:
Running
Running
Download src/services/cronService.js from aliroohan179/face: direct link, hf CLI and curl.
- Browser
- Download file 944 Bytes
-
https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/services/cronService.js
- Command line
-
hf download hf://spaces/aliroohan179/face/src/services/cronService.js
-
curl -L -o cronService.js https://huggingface.co/spaces/aliroohan179/face/resolve/main/src/services/cronService.js
944 Bytes
| const cron = require('node-cron'); | |
| /** | |
| * Initializes all backend cron jobs. | |
| */ | |
| const initCronJobs = () => { | |
| const schedule = '*/30 * * * *'; // Default to every 30 minutes | |
| const targetUrl = "https://aliroohan179-face.hf.space/api/health"; | |
| if (!targetUrl) { | |
| console.log('ℹ️ Cron Service: No CRON_TARGET_URL configured. Cron job is idle.'); | |
| return; | |
| } | |
| console.log(`⏰ Cron Service: Scheduled job with pattern "${schedule}" to call URL: ${targetUrl}`); | |
| cron.schedule(schedule, async () => { | |
| console.log(`⏰ Cron Service: Executing scheduled job at ${new Date().toISOString()}`); | |
| try { | |
| const response = await fetch(targetUrl); | |
| console.log(`✅ Cron Service: API call to ${targetUrl} succeeded with status ${response.status}`); | |
| } catch (error) { | |
| console.error(`❌ Cron Service: API call to ${targetUrl} failed. Error:`, error.message); | |
| } | |
| }); | |
| }; | |
| module.exports = { initCronJobs }; | |