@abtnode/cron 中文文档教程
Cron Scheduler
围绕 cron
的简单包装器,用于管理 ABT 节点中的作业
Usage
yarn add @abtnode/core
然后:
const Cron = require('@abtnode/cron');
const fetchIp = () => console.log('fetching ip...');
// Initialize cron scheduler
Cron.init({
context: {},
jobs: [
{
name: 'refetch-ip',
time: '0 */30 * * * *', // refetch every 30 minutes
fn: fetchIp,
},
],
onError: (error, name) => {
console.log(`Run job ${name} failed with error: ${error.message}`);
},
});
Cron Scheduler
A simple wrapper around cron
to manage jobs in ABT Node
Usage
yarn add @abtnode/core
Then:
const Cron = require('@abtnode/cron');
const fetchIp = () => console.log('fetching ip...');
// Initialize cron scheduler
Cron.init({
context: {},
jobs: [
{
name: 'refetch-ip',
time: '0 */30 * * * *', // refetch every 30 minutes
fn: fetchIp,
},
],
onError: (error, name) => {
console.log(`Run job ${name} failed with error: ${error.message}`);
},
});