mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-04 12:15:41 -04:00
feat: add notice every 30 minutes for next data refresh
every 30 minutes, console will print date on when next data refresh is
This commit is contained in:
@@ -13,6 +13,7 @@ import chalk from 'chalk';
|
|||||||
import ejs from 'ejs';
|
import ejs from 'ejs';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import cron, { schedule } from 'node-cron';
|
import cron, { schedule } from 'node-cron';
|
||||||
|
import * as crons from 'cron';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Old CJS variables converted to ESM
|
Old CJS variables converted to ESM
|
||||||
@@ -1764,9 +1765,24 @@ async function initialize()
|
|||||||
const start = performance.now();
|
const start = performance.now();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const validation = crons.validateCronExpression( envTaskCronSync );
|
||||||
|
if ( !validation.valid )
|
||||||
|
{
|
||||||
|
Log.error( `core`, chalk.yellow( `[schedule]` ), chalk.white( `❌` ),
|
||||||
|
chalk.redBright( `<msg>` ), chalk.gray( `Specified cron schedule is not valid` ),
|
||||||
|
chalk.redBright( `<schedule>` ), chalk.whiteBright.bgBlack( ` ${ envTaskCronSync } ` ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const cronNextRunDt = new Date( crons.sendAt( envTaskCronSync ) );
|
||||||
|
const cronNextRun = moment( cronNextRunDt ).format( 'MM-DD-YYYY h:mm A' );
|
||||||
|
|
||||||
Log.info( `core`, chalk.yellow( `[schedule]` ), chalk.white( `ℹ️` ),
|
Log.info( `core`, chalk.yellow( `[schedule]` ), chalk.white( `ℹ️` ),
|
||||||
chalk.blueBright( `<msg>` ), chalk.gray( `Container set to refresh IPTV data on specified cron duration` ),
|
chalk.blueBright( `<msg>` ), chalk.gray( `TVApp2 will refresh channel and guide data at` ),
|
||||||
chalk.blueBright( `<schedule>` ), chalk.whiteBright.bgBlack( ` ${ envTaskCronSync } ` ) );
|
chalk.blueBright( `<schedule>` ), chalk.whiteBright.gray( ` ${ envTaskCronSync } ` ),
|
||||||
|
chalk.blueBright( `<nextrun>` ), chalk.whiteBright.gray( ` ${ cronNextRun } ` ),
|
||||||
|
chalk.blueBright( `<nextrunIso>` ), chalk.whiteBright.gray( ` ${ cronNextRunDt } ` ) );
|
||||||
|
}
|
||||||
|
|
||||||
Log.info( `core`, chalk.yellow( `[initiate]` ), chalk.white( `ℹ️` ),
|
Log.info( `core`, chalk.yellow( `[initiate]` ), chalk.white( `ℹ️` ),
|
||||||
chalk.blueBright( `<msg>` ), chalk.gray( `Starting TVApp2 container. Assigning bound IP to host network adapter` ),
|
chalk.blueBright( `<msg>` ), chalk.gray( `Starting TVApp2 container. Assigning bound IP to host network adapter` ),
|
||||||
@@ -2312,7 +2328,7 @@ const server = http.createServer( ( request, response ) =>
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialize Cron
|
Crons > Next Sync
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cron.schedule( envTaskCronSync, async() =>
|
cron.schedule( envTaskCronSync, async() =>
|
||||||
@@ -2323,3 +2339,31 @@ cron.schedule( envTaskCronSync, async() =>
|
|||||||
|
|
||||||
await initialize();
|
await initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
Crons > Announce Next Sync
|
||||||
|
should show every 30 minutes
|
||||||
|
*/
|
||||||
|
|
||||||
|
cron.schedule( '*/30 * * * *', async() =>
|
||||||
|
{
|
||||||
|
const validation = crons.validateCronExpression( envTaskCronSync );
|
||||||
|
if ( !validation.valid )
|
||||||
|
{
|
||||||
|
Log.error( `core`, chalk.yellow( `[schedule]` ), chalk.white( `❌` ),
|
||||||
|
chalk.redBright( `<msg>` ), chalk.gray( `Specified cron schedule is not valid. Re-write the cron so that it is properly formatted` ),
|
||||||
|
chalk.redBright( `<env>` ), chalk.gray( `TASK_CRON_SYNC` ),
|
||||||
|
chalk.redBright( `<schedule>` ), chalk.whiteBright.bgBlack( ` ${ envTaskCronSync } ` ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const cronNextRunDt = new Date( crons.sendAt( envTaskCronSync ) );
|
||||||
|
const cronNextRun = moment( cronNextRunDt ).format( 'MM-DD-YYYY h:mm A' );
|
||||||
|
|
||||||
|
Log.info( `core`, chalk.yellow( `[schedule]` ), chalk.white( `ℹ️` ),
|
||||||
|
chalk.blueBright( `<msg>` ), chalk.gray( `Next IPTV data refresh at` ),
|
||||||
|
chalk.blueBright( `<schedule>` ), chalk.whiteBright.gray( ` ${ envTaskCronSync } ` ),
|
||||||
|
chalk.blueBright( `<nextrun>` ), chalk.whiteBright.gray( ` ${ cronNextRun } ` ),
|
||||||
|
chalk.blueBright( `<nextrunIso>` ), chalk.whiteBright.gray( ` ${ cronNextRunDt } ` ) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|||||||
29
tvapp2/package-lock.json
generated
29
tvapp2/package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
|
"cron": "^4.3.0",
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
"express": "5.1.0",
|
"express": "5.1.0",
|
||||||
"moment": "2.30.1",
|
"moment": "2.30.1",
|
||||||
@@ -298,6 +299,12 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/luxon": {
|
||||||
|
"version": "3.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.6.2.tgz",
|
||||||
|
"integrity": "sha512-R/BdP7OxEMc44l2Ex5lSXHoIXTB2JLNa3y2QISIbr58U/YcsffyQrYW//hZSdrfxrjRZj3GcUoxMPGdO8gSYuw==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/uuid": {
|
"node_modules/@types/uuid": {
|
||||||
"version": "10.0.0",
|
"version": "10.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz",
|
||||||
@@ -843,6 +850,19 @@
|
|||||||
"node": ">=6.6.0"
|
"node": ">=6.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/cron": {
|
||||||
|
"version": "4.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cron/-/cron-4.3.0.tgz",
|
||||||
|
"integrity": "sha512-ciiYNLfSlF9MrDqnbMdRWFiA6oizSF7kA1osPP9lRzNu0Uu+AWog1UKy7SkckiDY2irrNjeO6qLyKnXC8oxmrw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/luxon": "~3.6.0",
|
||||||
|
"luxon": "~3.6.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
@@ -2930,6 +2950,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/luxon": {
|
||||||
|
"version": "3.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.6.1.tgz",
|
||||||
|
"integrity": "sha512-tJLxrKJhO2ukZ5z0gyjY1zPh3Rh88Ej9P7jNrZiHMUXHae1yvI2imgOZtL1TO8TW6biMMKfTtAOoEJANgtWBMQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/math-intrinsics": {
|
"node_modules/math-intrinsics": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
"iptv"
|
"iptv"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"cron": "^4.3.0",
|
||||||
"node-cron": "^4.0.3",
|
"node-cron": "^4.0.3",
|
||||||
"playwright": "^1.52.0",
|
"playwright": "^1.52.0",
|
||||||
"user-agents": "^1.1.537",
|
"user-agents": "^1.1.537",
|
||||||
|
|||||||
Reference in New Issue
Block a user